Add dynamic ansible inventory from terraform state
This commit is contained in:
parent
bccc07f806
commit
70578f2a13
11 changed files with 84 additions and 51 deletions
|
@ -2,13 +2,17 @@
|
|||
- name: Change password
|
||||
hosts: all
|
||||
become: true
|
||||
vars_prompt:
|
||||
- name: name
|
||||
prompt: User
|
||||
private: false
|
||||
- name: password
|
||||
prompt: Password
|
||||
encrypt: sha512_crypt
|
||||
confirm: true
|
||||
salt_size: 7
|
||||
tasks:
|
||||
- name: Get new password
|
||||
ansible.builtin.pause:
|
||||
prompt: Enter the new password
|
||||
echo: false
|
||||
register: new_user_password
|
||||
- name: Change password
|
||||
ansible.builtin.user:
|
||||
name: "{{ interactive_user }}"
|
||||
password: "{{ new_user_password.user_input | password_hash('sha512') }}"
|
||||
name: "{{ user }}"
|
||||
password: "{{ password }}"
|
||||
|
|
|
@ -31,13 +31,15 @@ class FilterModule(object):
|
|||
})
|
||||
return result
|
||||
|
||||
def vault_hosts_backup_to_gatus(self, hosts):
|
||||
def vault_hosts_backup_to_gatus(self, hostvars):
|
||||
result = []
|
||||
for name, host_data in hosts.items():
|
||||
for name, host_data in hostvars.items():
|
||||
if not host_data.get("host_backup_gatus_token"):
|
||||
continue
|
||||
result.append({
|
||||
"name": f"backup@{name}",
|
||||
"group": "8-backups",
|
||||
"token": host_data["backup"]["gatus_token"],
|
||||
"token": host_data["host_backup_gatus_token"],
|
||||
"alerts": self.default_alerts,
|
||||
})
|
||||
return result
|
||||
|
|
|
@ -9,8 +9,8 @@ backup_msg_success: "Backup successful"
|
|||
|
||||
backup_curl_base: 'curl -L -m 10 --retry 5'
|
||||
backup_hc_curl_base: '{{ backup_curl_base }} -X POST -H "Content-Type: text/plain"'
|
||||
backup_gatus_curl_base: '{{ backup_curl_base }} -X POST -H "Authorization: Bearer {{ host_backup.gatus_token }}"'
|
||||
backup_hc_url: '{{ host_backup.hc_url }}'
|
||||
backup_gatus_curl_base: '{{ backup_curl_base }} -X POST -H "Authorization: Bearer {{ host_backup_gatus_token }}"'
|
||||
backup_hc_url: '{{ host_backup_hc_url }}'
|
||||
backup_gatus_url: 'https://status.serguzim.me/api/v1/endpoints/8-backups_backup@{{ ansible_facts.hostname }}/external'
|
||||
|
||||
backup_hc_command_start: '{{ backup_hc_curl_base }} --data "{{ backup_msg_start }}" {{ backup_hc_url }}/start'
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
import /etc/caddy/snippets
|
||||
|
||||
http://{{ host_vpn.domain }} {
|
||||
http://{{ host_vpn_domain }} {
|
||||
import vpn_only
|
||||
|
||||
metrics
|
||||
|
|
|
@ -3,7 +3,7 @@ gatus_svc:
|
|||
domain: "{{ all_services | service_get_domain(role_name) }}"
|
||||
port: 8080
|
||||
|
||||
gatus_external_endpoints_backups: "{{ vault_hosts | vault_hosts_backup_to_gatus() }}"
|
||||
gatus_external_endpoints_backups: "{{ hostvars | vault_hosts_backup_to_gatus() }}"
|
||||
|
||||
gatus_endpoints_hosts: "{{ opentofu.hosts | hosts_to_gatus() }}"
|
||||
gatus_endpoints_services: "{{ all_services | services_to_gatus() }}"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue