File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -61,11 +61,12 @@ attackmate_api_server_url: "https://github.com/ait-testbed/attackmate-api-server
6161attackmate_api_server_version : " main"
6262attackmate_api_server_dest : " {{ attackmate_shared_dir }}/attackmate-api-server"
6363
64- attackmate_api_logs_to_disk : " False"
64+ attackmate_api_logs_to_disk : False
6565attackmate_api_log_dir : " /var/log/attackmate-api"
6666
6767attackmate_api_bin_path : " /usr/local/bin/attackmate-api"
6868attackmate_api_service_path : " /etc/systemd/system/attackmate-api.service"
6969attackmate_ssl_key_path : " /etc/ssl/private/attackmate.key"
7070attackmate_ssl_cert_path : " /etc/ssl/certs/attackmate.pem"
7171attackmate_api_server_port : 8445
72+ attackmate_api_plain_users : {}
Original file line number Diff line number Diff line change 111111 - { path: "{{ attackmate_ssl_key_path }}", mode: '0640' }
112112 - { path: "{{ attackmate_ssl_cert_path }}", mode: '0644' }
113113
114+ # --- User hashes for .env file (Optional) ---
115+
116+ - name : Install argon2-cffi for hash generation
117+ ansible.builtin.pip :
118+ name : argon2-cffi
119+ state : present
120+ delegate_to : localhost
121+ become : false
122+ when : attackmate_api_plain_users | length > 0
123+
124+ - name : Generate argon2 hashes for API users
125+ ansible.builtin.shell :
126+ cmd : " python3 -c \" from argon2 import PasswordHasher; ph = PasswordHasher(); print(ph.hash('{{ item.value }}'))\" "
127+ loop : " {{ attackmate_api_plain_users | dict2items }}"
128+ register : argon2_hashes
129+ changed_when : false
130+ delegate_to : localhost
131+ become : false
132+ # no_log: true
133+ when : attackmate_api_plain_users | length > 0
134+
135+ - name : Build USERS json string
136+ ansible.builtin.set_fact :
137+ attackmate_api_users : >-
138+ {{ dict(argon2_hashes.results | map(attribute='item.key') |
139+ zip(argon2_hashes.results | map(attribute='stdout'))) | to_json }}
140+ # no_log: true
141+ when : attackmate_api_plain_users | length > 0
114142
115143# --- Env file ---
116144
You can’t perform that action at this time.
0 commit comments