fix al container. ora va per davvero e ci sono le password in un .env.yml

This commit is contained in:
Freek Kettone 2025-09-07 12:53:47 +02:00
parent 75dfd49a53
commit 5941ed27b2
9 changed files with 35 additions and 20 deletions

8
.gitignore vendored
View file

@ -1,3 +1,6 @@
# passwords
.env.yml
# ---> Ansible # ---> Ansible
*.retry *.retry
@ -14,8 +17,8 @@ crash.log
crash.*.log crash.*.log
# Exclude all .tfvars files, which are likely to contain sensitive data, such as # Exclude all .tfvars files, which are likely to contain sensitive data, such as
# password, private keys, and other secrets. These should not be part of version # password, private keys, and other secrets. These should not be part of version
# control as they are data points which are potentially sensitive and subject # control as they are data points which are potentially sensitive and subject
# to change depending on the environment. # to change depending on the environment.
*.tfvars *.tfvars
*.tfvars.json *.tfvars.json
@ -39,4 +42,3 @@ override.tf.json
# Ignore CLI configuration files # Ignore CLI configuration files
.terraformrc .terraformrc
terraform.rc terraform.rc

View file

@ -14,6 +14,11 @@ Teniamo libero il 10.10.0.21 per il povero container che sta venendo abbattuto e
`ansible-galaxy collection install -r requirements.yml` `ansible-galaxy collection install -r requirements.yml`
In più, bisogna creare un file `.env.yml` nella root del progetto con questo template
`
PROXMOX_PASSWORD: "segretissima0"
XMPP_PASSWORD: "segretissima1"
`
### Per dare vita al container e alla configurazione di Prosody ### Per dare vita al container e alla configurazione di Prosody
#### _mado quanto è swag sta cosa_ #### _mado quanto è swag sta cosa_

View file

@ -1,4 +1,3 @@
# Variabili per la creazione del container # Variabili per la creazione del container
root_password: "{{ lookup('env', 'XMPP_PASSWORD') }}" # root_password: "{{ lookup('env', 'XMPP_PASSWORD') }}" #dovrebbe essere nel file .env
ssh_public_key: "{{ lookup('file', '~/.ssh/ansible.pub') }}" ssh_public_key: "{{ lookup('file', '~/.ssh/ansible.pub') }}"

View file

@ -1,3 +1,3 @@
proxmox_host: 192.168.1.100:8006 proxmox_host: 192.168.1.100:8006
proxmox_user: root@pam proxmox_user: root@pam
proxmox_password: "{{ lookup('env', 'PROXMOX_PASSWORD') }}" # proxmox_password: "{{ lookup('env', 'PROXMOX_PASSWORD') }}" #dovrebbe essere nel file .env

View file

@ -1,9 +1,13 @@
- name: Configura container LXC - name: Configura container LXC
hosts: lxc_containers hosts: lxc_containers
gather_facts: false
become: true
vars_files:
- ../.env.yml
vars: vars:
ssh_public_key: "{{ lookup('file', '~/.ssh/ansible.pub') }}" ssh_public_key: "{{ lookup('file', '~/.ssh/ansible.pub') }}"
gather_facts: false
become: yes
tasks: tasks:
- name: Wait until SSH is fully ready (Ansible login confirms availability) - name: Wait until SSH is fully ready (Ansible login confirms availability)

View file

@ -1,4 +1,6 @@
- name: Configura Prosody (xmpp) sul container - name: Configura Prosody (xmpp) sul container
hosts: lxc_containers hosts: lxc_containers
vars_files:
- ../.env.yml
roles: roles:
- prosody - prosody

View file

@ -1,8 +1,12 @@
- name: Crea container lxc per prosody (xmpp) - name: Crea container lxc per prosody (xmpp)
hosts: proxmox_nodes hosts: proxmox_nodes
gather_facts: false gather_facts: false
vars_files:
- ../.env.yml
vars: vars:
root_password: "{{ lookup('env', 'XMPP_PASSWORD') }}" # root_password: "{{ lookup('env', 'XMPP_PASSWORD') }}" #dovrebbe essere nel file .env
ssh_public_key: "{{ lookup('file', '~/.ssh/ansible.pub') }}" ssh_public_key: "{{ lookup('file', '~/.ssh/ansible.pub') }}"
vmid: 121 vmid: 121
@ -11,7 +15,7 @@
community.general.proxmox: community.general.proxmox:
api_host: "{{ proxmox_url }}" api_host: "{{ proxmox_url }}"
api_user: "{{ proxmox_user }}" api_user: "{{ proxmox_user }}"
api_password: "{{ proxmox_password }}" api_password: "{{ PROXMOX_PASSWORD }}"
vmid: "{{ vmid }}" vmid: "{{ vmid }}"
node: milan node: milan
hostname: xmpp hostname: xmpp
@ -22,7 +26,7 @@
netif: netif:
net0: "name=eth0,bridge=vmbr1,ip=10.10.0.21/16,gw=10.10.0.1" net0: "name=eth0,bridge=vmbr1,ip=10.10.0.21/16,gw=10.10.0.1"
pubkey: "{{ ssh_public_key }}" pubkey: "{{ ssh_public_key }}"
password: "{{ root_password }}" password: "{{ XMPP_PASSWORD }}"
features: "nesting=1" features: "nesting=1"
state: present state: present
delegate_to: localhost delegate_to: localhost
@ -32,7 +36,7 @@
community.general.proxmox: community.general.proxmox:
api_host: "{{ proxmox_url }}" api_host: "{{ proxmox_url }}"
api_user: "{{ proxmox_user }}" api_user: "{{ proxmox_user }}"
api_password: "{{ proxmox_password }}" api_password: "{{ PROXMOX_PASSWORD }}"
vmid: "{{ vmid }}" vmid: "{{ vmid }}"
node: milan node: milan
state: started # Tutto questo blocco è riassumibile in questa riga state: started # Tutto questo blocco è riassumibile in questa riga

View file

@ -1,4 +1,4 @@
prosody_domain: "xmpp.hackinpovo.it" prosody_domain: "xmpp.hackinpovo.it"
prosody_admin: "admin@{{ prosody_domain }}" prosody_admin: "admin@{{ prosody_domain }}"
prosody_package: prosody prosody_package: prosody
xmpp_admin_password: "{{ lookup('env', 'XMPP_ADMIN_PASSWORD') }}" # xmpp_admin_password: "{{ lookup('env', 'XMPP_PASSWORD') }}" # Dovrebbe essere nel file .env.yml

View file

@ -19,10 +19,9 @@
state: started state: started
enabled: yes enabled: yes
- name: Create XMPP admin user - name: Create XMPP admin user non-interactively
ansible.builtin.expect: ansible.builtin.command:
command: prosodyctl adduser admin@{{ xmpp_domain }} cmd: prosodyctl register admin {{ prosody_domain }} {{ XMPP_PASSWORD }}
responses: args:
"Enter new password:": "{{ xmpp_admin_password }}" creates: "/var/lib/prosody/{{ prosody_domain }}/accounts/admin.dat"
"Retype new password:": "{{ xmpp_admin_password }}" become: yes
become: yes