--- - name: clean puppet build directory local_action: module: file path: "{{ inventory_dir }}/build/puppet" state: absent run_once: True tags: puppet_fast - name: create puppet build directories local_action: module: file path: "{{ inventory_dir }}/{{ item }}" state: directory loop: - build/puppet/global_vars - build/puppet/host_vars - build/puppet/facts run_once: True tags: puppet_fast - name: create puppet build host vars directories local_action: module: file path: "{{ inventory_dir }}/build/puppet/host_vars/{{ inventory_hostname }}" state: directory tags: puppet_fast - name: dump hostvars local_action: module: copy dest: "{{ inventory_dir }}/build/puppet/global_vars/hostvars.json" content: "{'hostvars': {{ hostvars }} }" run_once: True tags: puppet_fast - name: dump this local_action: module: copy dest: "{{ inventory_dir }}/build/puppet/host_vars/{{ inventory_hostname }}/this.json" content: "{{ hostvars[inventory_hostname] }}" tags: puppet_fast - name: install config manager command: dnf install -y 'dnf-command(config-manager)' when: ansible_distribution_file_variety == 'RedHat' and ansible_distribution_major_version == '9' - name: enable crb command: dnf config-manager --set-enabled crb when: ansible_distribution_file_variety == 'RedHat' and ansible_distribution_major_version == '9' - name: install epel package: name: epel-release when: ansible_distribution_file_variety == 'RedHat' - name: enable openvox ansible.builtin.dnf: disable_gpg_check: true name: - https://yum.voxpupuli.org/openvox8-release-el-10.noarch.rpm when: ansible_distribution_file_variety == 'RedHat' and ansible_distribution_major_version == '10' - name: install packages package: name: - "{{ puppet.by_os[ ansible_distribution_file_variety ][ ansible_distribution_major_version ].package }}" - unzip - name: get facts command: facter -y register: facter_output tags: puppet_fast - name: dump facts local_action: module: copy dest: "{{ inventory_dir }}/build/puppet/facts/{{ inventory_hostname }}.yaml" content: "{{ facter_output.stdout }}" delegate_to: 127.0.0.1 tags: puppet_fast - name: compile puppet catalogs local_action: module: command cmd: "{{ inventory_dir }}/up.py {{ inventory_dir }}/build/puppet {{ inventory_dir }}/puppet/modules {{ inventory_dir }}/puppet/site {% for host in ansible_play_batch %}{{ host }} {% endfor %}" tags: puppet_fast run_once: True - name: simulate exported resources local_action: module: command cmd: "./pseudo_resource_exporter.py" chdir: "{{ inventory_dir }}" tags: puppet_fast run_once: True - name: package catalog archive: path: "{{ inventory_dir }}/build/puppet/build/output/{{ inventory_hostname }}" dest: "{{ inventory_dir }}/build/puppet/puppet_catalog_{{ inventory_hostname }}.zip" format: zip delegate_to: 127.0.0.1 tags: puppet_fast - name: create remote temporary directory tempfile: state: directory register: remote_temp tags: puppet_fast - name: unpackage catalog unarchive: src: "{{ inventory_dir }}/build/puppet/puppet_catalog_{{ inventory_hostname }}.zip" dest: "{{ remote_temp.path }}" tags: puppet_fast - name: preview catalog command: puppet apply --catalog {{ remote_temp.path }}/{{ inventory_hostname }}/catalog.json --noop --test --modulepath={{ remote_temp.path }}/{{ inventory_hostname }}/modules/ register: catalog_apply tags: puppet_fast - name: display catalog preview stdout debug: msg: "{{ catalog_apply.stdout_lines }}" tags: puppet_fast - name: display catalog preview stderr debug: msg: "{{ catalog_apply.stderr_lines }}" tags: puppet_fast - name: pause to confirm pause: tags: pause - name: apply catalog command: puppet apply --catalog {{ remote_temp.path }}/{{ inventory_hostname }}/catalog.json --modulepath={{ remote_temp.path }}/{{ inventory_hostname }}/modules/ register: catalog_apply tags: puppet_fast - name: display catalog apply stdout debug: msg: "{{ catalog_apply.stdout_lines }}" tags: puppet_fast - name: display catalog apply stderr debug: msg: "{{ catalog_apply.stderr_lines }}" tags: puppet_fast - name: clean up remote temporary directory file: state: absent path: "{{ remote_temp.path }}" tags: puppet_fast - name: clean up local temporary directory file: state: absent path: "{{ inventory_dir }}/build/puppet/" delegate_to: 127.0.0.1 tags: puppet_fast run_once: True