#!/usr/bin/ansible-playbook --- - hosts: all gather_facts: false environment: PATH: /bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/usr/local/cmcluster/bin/ tasks: - name: "Gather facts" ignore_unreachable: true block: - name: "Gather facts for RHEL > 5" ansible.builtin.setup: - name: set_fact python_value ansible.builtin.set_fact: python_value: auto_legacy rescue: - name: set_fact with_raw_module ansible.builtin.set_fact: with_raw_module: true - name: block when with_raw_module when: with_raw_module is defined and with_raw_module block: - name: DEBUG ansible.builtin.debug: var: item with_items: - "{% for host in hostvars %}{{ host }}{% endfor %}" - name: Split file ansible.builtin.shell: | cat script.sh | gzip | openssl base64 | split -b 6258 --additional-suffix .asc - script- args: chdir: files delegate_to: localhost - name: Find ansible.builtin.find: file_type: file paths: files/ patterns: 'script-*' register: f delegate_to: localhost - name: Slurp ansible.builtin.slurp: src: "{{ item }}" register: slurp_shell_code delegate_to: localhost with_items: - "{{ f.files | map(attribute='path') |list }}" - name: Copy shell script ansible.builtin.raw: | cat > script.sh.asc.{{ ansible_loop.index0 }} <<-EOF {{ item.content | b64decode }} EOF args: executable: /bin/bash loop_control: extended: true with_items: - "{{ slurp_shell_code.results }}" - name: Mkdir /usr/local/plop/ ansible.builtin.raw: sudo install -d -m 750 /usr/local/plop/ - name: Merge file ansible.builtin.raw: cat script.sh.asc.* | openssl base64 -d | gzip -d > script.sh - name: Clean temp files ansible.builtin.raw: rm -f script.sh.asc.* - name: Mv shell script ansible.builtin.raw: sudo mv script.sh /usr/local/plop/script.sh - name: Launch script ansible.builtin.raw: sudo bash /usr/local/plop/script.sh