From 5e735cf4539a54d85c6c0945d7dfbca0455a25ac Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Thu, 22 Jun 2023 16:16:32 +0200 Subject: [PATCH] tls_server is a special machine --- ansible/machines.yml | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/ansible/machines.yml b/ansible/machines.yml index 804a300..e3abaa8 100644 --- a/ansible/machines.yml +++ b/ansible/machines.yml @@ -1,48 +1,46 @@ - 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 failed_when: ret.rc != 0 - name: "Stop machine TLS" machinectl: state: stopped - machines: "{{ build_host.tls_machine }}" - tls_machine: "{{ build_host.tls_machine }}" - when: build_host.tls_machine in build_host.machines_changed + machines: "{{ vars[vars['inventory_hostname']]['general']['tls_server'] }}" + when: vars[vars['inventory_hostname']]['general']['tls_server'] in machines_changed - name: "Remove TLS files directory" file: - path: "/var/lib/risotto/configurations/{{ build_host.tls_machine }}" + path: "/var/lib/risotto/configurations/{{ vars[vars['inventory_hostname']]['general']['tls_server'] }}" 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" unarchive: src: /tmp/new_configurations/machines.tar dest: "/var/lib/risotto/configurations/" - include: "{{ build_host.tls_machine }}" + include: "{{ vars[vars['inventory_hostname']]['general']['tls_server'] }}" owner: 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" machinectl: state: started - machines: "{{ build_host.tls_machine }}" - tls_machine: "{{ build_host.tls_machine }}" - when: build_host.tls_machine in build_host.machines_changed + machines: "{{ vars[vars['inventory_hostname']]['general']['tls_server'] }}" + when: vars[vars['inventory_hostname']]['general']['tls_server'] in machines_changed -- name: "Stop machines with new configuration {{ build_host.machines_changed }}" +- name: "Stop machines with new configuration {{ machines_changed }}" machinectl: state: stopped - machines: "{{ build_host.machines_changed }}" - tls_machine: "{{ build_host.tls_machine }}" + machines: "{{ machines_changed }}" + tls_machine: "{{ vars[vars['inventory_hostname']]['general']['tls_server'] }}" - name: "Remove files directory" file: path: "/var/lib/risotto/configurations/{{ item }}" state: absent - loop: "{{ build_host.machines_changed }}" + loop: "{{ machines_changed }}" - name: "Copy configuration" unarchive: @@ -50,19 +48,19 @@ dest: /var/lib/risotto/configurations/ owner: root group: root - when: build_host.machines_changed + when: machines_changed - name: "Enable machines" machinectl: state: enabled machines: "{{ vars | machineslist(only_name=True) }}" - tls_machine: "{{ build_host.tls_machine }}" + tls_machine: "{{ vars[vars['inventory_hostname']]['general']['tls_server'] }}" - name: "Start machines" machinectl: state: started 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" local_action: