##################################################### # Per step puppet configuration of the baremetal host ##################################################### - name: Write the config_step hieradata become: true no_log: True copy: content: "{{ dict(step=step|int) | to_json }}" dest: /etc/puppet/{{ ansible_check_mode | bool | ternary('check-mode/', '') }}hieradata/config_step.json force: true mode: '0600' check_mode: false tags: - host_config - name: Run puppet host configuration for step {{ step }} become: true async: 3600 poll: 0 when: enable_puppet|bool shell: >- set -o pipefail; puppet apply {{ host_puppet_config_debug | default('') }} --modulepath=/etc/puppet/modules:/opt/stack/puppet-modules:/usr/share/openstack-puppet/modules --detailed-exitcodes --summarize --color=false {{ ansible_check_mode | bool | ternary('--noop', '') }} {{ ansible_check_mode | bool | ternary('--hiera_config /etc/puppet/check-mode/hiera.yaml', '') }} /var/lib/tripleo-config/{{ ansible_check_mode | bool | ternary('check-mode/', '') }}puppet_step_config.pp 2>&1 | logger -s -t puppet-user register: puppet_host_async_result no_log: true tags: - host_config check_mode: false - name: Wait for puppet host configuration to finish async_status: jid: "{{ puppet_host_async_result.ansible_job_id }}" register: puppet_host_outputs until: puppet_host_outputs.finished retries: 1200 delay: 3 failed_when: - (not puppet_host_outputs.finished) or (puppet_host_outputs.rc is defined and puppet_host_outputs.rc not in [0, 2]) when: - not (ansible_check_mode | bool) - enable_puppet|bool tags: - host_config - name: "Debug output for task: Run puppet host configuration for step {{ step }}" debug: var: puppet_host_outputs.stdout_lines | default([]) | union(puppet_host_outputs.stderr_lines | default([])) when: - not ansible_check_mode|bool - enable_puppet | bool - puppet_host_outputs.rc is defined changed_when: puppet_host_outputs.rc == 2 failed_when: puppet_host_outputs.rc not in [0, 2] tags: - host_config ####################################### # Pre-cache facts for puppet containers ####################################### # We don't want the pre-cache tasks to be skipped in dry-run so we force # check_mode to "no". # https://bugzilla.redhat.com/show_bug.cgi?id=1738529 - name: Pre-cache facts for puppet containers include_role: name: tripleo_puppet_cache tags: - container_config - container_config_tasks ####################################### # Generate config via puppet containers ####################################### - name: Include container-puppet tasks (generate config) during step 1 include_tasks: generate-config-tasks.yaml when: step|int == 1 tags: - container_config ##################################### # Per step starting of the containers ##################################### - name: Per step starting of the containers using tripleo-ansible become: true environment: TRIPLEO_MINOR_UPDATE: '{{ tripleo_minor_update | default(false) }}' block: - name: "Manage containers for step {{ step }} with tripleo-ansible" include_role: name: tripleo_container_manage vars: tripleo_container_manage_concurrency: 5 tripleo_container_manage_cli: "{{ container_cli }}" tripleo_container_manage_config: "/var/lib/tripleo-config/container-startup-config/step_{{ step }}" tripleo_container_manage_config_id: "tripleo_step{{ step }}" tripleo_container_manage_debug: "{{ enable_debug | bool }}" tripleo_container_manage_healthcheck_disabled: "{{ container_healthcheck_disabled | bool }}" tripleo_container_manage_log_path: "{{ container_log_stdout_path }}" tripleo_container_manage_config_patterns: '*.json' tripleo_container_manage_check_puppet_config: true tags: - container_startup_configs ######################################################## # Bootstrap tasks - run any tasks that have been defined ######################################################## - name: "Clean container_puppet_tasks for {{ansible_facts['hostname'] | lower}} step {{step}}" become: true file: path: /var/lib/container-puppet/container-puppet-tasks{{step}}.json state: absent tags: - container_config_tasks - name: Calculate container_puppet_tasks for {{ansible_facts['hostname'] | lower}} step {{step}} set_fact: "{{'host_container_puppet_tasks_' ~ step}}": "{{lookup('vars', 'host_container_puppet_tasks_' ~ step, default=[]) | union([item])}}" loop: "{{container_puppet_tasks.get('step_' ~ step, [])}}" when: (groups[item.service_name] | default ([]) | map('extract', hostvars, 'inventory_hostname') | sort | first | lower) == ansible_facts['hostname'] | lower vars: container_puppet_tasks: "{{ lookup('file', tripleo_role_name + '/container_puppet_tasks.yaml', errors='ignore') | default({}, True) | from_yaml }}" tags: - container_config_tasks - name: Include container-puppet tasks for step {{step}} include_tasks: host-container-puppet-tasks.yaml when: ('host_container_puppet_tasks_' ~ step) is defined tags: - container_config_tasks