tls_server is a special machine

This commit is contained in:
egarette@silique.fr 2023-06-22 16:16:32 +02:00
parent 7ebcff86cb
commit 5e735cf453

View file

@ -1,48 +1,46 @@
- name: "Rebuild images" - name: "Rebuild images"
ansible.builtin.shell: "/usr/local/sbin/update_images just_need_images" ansible.builtin.shell: "/usr/local/sbin/update_images {{ vars[vars['inventory_hostname']]['general']['tls_server'] }} do_not_start"
register: ret register: ret
failed_when: ret.rc != 0 failed_when: ret.rc != 0
- name: "Stop machine TLS" - name: "Stop machine TLS"
machinectl: machinectl:
state: stopped state: stopped
machines: "{{ build_host.tls_machine }}" machines: "{{ vars[vars['inventory_hostname']]['general']['tls_server'] }}"
tls_machine: "{{ build_host.tls_machine }}" when: vars[vars['inventory_hostname']]['general']['tls_server'] in machines_changed
when: build_host.tls_machine in build_host.machines_changed
- name: "Remove TLS files directory" - name: "Remove TLS files directory"
file: file:
path: "/var/lib/risotto/configurations/{{ build_host.tls_machine }}" path: "/var/lib/risotto/configurations/{{ vars[vars['inventory_hostname']]['general']['tls_server'] }}"
state: absent state: absent
when: build_host.tls_machine in build_host.machines_changed when: vars[vars['inventory_hostname']]['general']['tls_server'] in machines_changed
- name: "Copy TLS configuration" - name: "Copy TLS configuration"
unarchive: unarchive:
src: /tmp/new_configurations/machines.tar src: /tmp/new_configurations/machines.tar
dest: "/var/lib/risotto/configurations/" dest: "/var/lib/risotto/configurations/"
include: "{{ build_host.tls_machine }}" include: "{{ vars[vars['inventory_hostname']]['general']['tls_server'] }}"
owner: root owner: root
group: root group: root
when: build_host.tls_machine in build_host.machines_changed when: vars[vars['inventory_hostname']]['general']['tls_server'] in machines_changed
- name: "Start machine TLS" - name: "Start machine TLS"
machinectl: machinectl:
state: started state: started
machines: "{{ build_host.tls_machine }}" machines: "{{ vars[vars['inventory_hostname']]['general']['tls_server'] }}"
tls_machine: "{{ build_host.tls_machine }}" when: vars[vars['inventory_hostname']]['general']['tls_server'] in machines_changed
when: build_host.tls_machine in build_host.machines_changed
- name: "Stop machines with new configuration {{ build_host.machines_changed }}" - name: "Stop machines with new configuration {{ machines_changed }}"
machinectl: machinectl:
state: stopped state: stopped
machines: "{{ build_host.machines_changed }}" machines: "{{ machines_changed }}"
tls_machine: "{{ build_host.tls_machine }}" tls_machine: "{{ vars[vars['inventory_hostname']]['general']['tls_server'] }}"
- name: "Remove files directory" - name: "Remove files directory"
file: file:
path: "/var/lib/risotto/configurations/{{ item }}" path: "/var/lib/risotto/configurations/{{ item }}"
state: absent state: absent
loop: "{{ build_host.machines_changed }}" loop: "{{ machines_changed }}"
- name: "Copy configuration" - name: "Copy configuration"
unarchive: unarchive:
@ -50,19 +48,19 @@
dest: /var/lib/risotto/configurations/ dest: /var/lib/risotto/configurations/
owner: root owner: root
group: root group: root
when: build_host.machines_changed when: machines_changed
- name: "Enable machines" - name: "Enable machines"
machinectl: machinectl:
state: enabled state: enabled
machines: "{{ vars | machineslist(only_name=True) }}" machines: "{{ vars | machineslist(only_name=True) }}"
tls_machine: "{{ build_host.tls_machine }}" tls_machine: "{{ vars[vars['inventory_hostname']]['general']['tls_server'] }}"
- name: "Start machines" - name: "Start machines"
machinectl: machinectl:
state: started state: started
machines: "{{ vars | machineslist(only_name=True) }}" machines: "{{ vars | machineslist(only_name=True) }}"
tls_machine: "{{ build_host.tls_machine }}" tls_machine: "{{ vars[vars['inventory_hostname']]['general']['tls_server'] }}"
- name: "Remove compressed files directory" - name: "Remove compressed files directory"
local_action: local_action: