diff --git a/ansible/fatimage.yml b/ansible/fatimage.yml index 0764477b3..7c44c1759 100644 --- a/ansible/fatimage.yml +++ b/ansible/fatimage.yml @@ -1,24 +1,22 @@ # Builder version of site.yml just installing binaries -- hosts: builder - become: no - gather_facts: no - tasks: - - name: Report hostname (= final image name) - command: hostname - - name: Run pre.yml hook vars: - appliances_environment_root: "{{ lookup('env', 'APPLIANCES_ENVIRONMENT_ROOT') }}" + # hostvars not available here, so have to recalculate environment root: + appliances_environment_root: "{{ ansible_inventory_sources | last | dirname }}" hook_path: "{{ appliances_environment_root }}/hooks/pre.yml" import_playbook: "{{ hook_path if hook_path | exists else 'noop.yml' }}" when: hook_path | exists +- import_playbook: validate.yml + when: appliances_validate | default(true) + - import_playbook: bootstrap.yml - name: Run post-bootstrap.yml hook vars: - appliances_environment_root: "{{ lookup('env', 'APPLIANCES_ENVIRONMENT_ROOT') }}" + # hostvars not available here, so have to recalculate environment root: + appliances_environment_root: "{{ ansible_inventory_sources | last | dirname }}" hook_path: "{{ appliances_environment_root }}/hooks/post-bootstrap.yml" import_playbook: "{{ hook_path if hook_path | exists else 'noop.yml' }}" when: hook_path | exists @@ -34,7 +32,7 @@ tasks_from: client-install.yml when: "'freeipa_client' in group_names" - # - import_playbook: filesystems.yml: + # import_playbook: filesystems.yml: - name: Install nfs packages dnf: name: nfs-utils @@ -51,7 +49,7 @@ become: yes gather_facts: yes tasks: - # - import_playbook: slurm.yml: + # import_playbook: slurm.yml: - name: Setup DB include_role: name: mysql @@ -73,7 +71,7 @@ name: openondemand tasks_from: vnc_compute.yml - # - import_playbook: monitoring.yml: + # import_playbook: monitoring.yml: - import_role: name: opensearch tasks_from: install.yml @@ -159,18 +157,20 @@ - name: Run post.yml hook vars: - appliances_environment_root: "{{ lookup('env', 'APPLIANCES_ENVIRONMENT_ROOT') }}" + # hostvars not available here, so have to recalculate environment root: + appliances_environment_root: "{{ ansible_inventory_sources | last | dirname }}" hook_path: "{{ appliances_environment_root }}/hooks/post.yml" import_playbook: "{{ hook_path if hook_path | exists else 'noop.yml' }}" when: hook_path | exists -- hosts: builder - become: yes +- name: Clean up and shutdown Packer VM + hosts: builder gather_facts: no + become: yes tasks: - # - meta: end_here - name: Cleanup image import_tasks: cleanup.yml - - name: Shutdown Packer VM - community.general.shutdown: + community.general.shutdown: + +... \ No newline at end of file diff --git a/ansible/site.yml b/ansible/site.yml index bb379399d..d72c29d8b 100644 --- a/ansible/site.yml +++ b/ansible/site.yml @@ -36,12 +36,4 @@ import_playbook: "{{ hook_path if hook_path | exists else 'noop.yml' }}" when: hook_path | exists -- name: Clean up and shutdown Packer VM - hosts: builder - gather_facts: no - become: yes - tasks: - - import_tasks: cleanup.yml - - community.general.shutdown: - ... \ No newline at end of file diff --git a/environments/.stackhpc/hooks/pre.yml b/environments/.stackhpc/hooks/pre.yml index 8e6f0e25e..c1bab2a1c 100644 --- a/environments/.stackhpc/hooks/pre.yml +++ b/environments/.stackhpc/hooks/pre.yml @@ -1,3 +1,10 @@ +- hosts: builder + become: no + gather_facts: no + tasks: + - name: Report hostname (= final image name) + command: hostname + - hosts: control:!builder become: yes gather_facts: false diff --git a/environments/common/inventory/group_vars/builder/defaults.yml b/environments/common/inventory/group_vars/builder/defaults.yml index 7c4ea5712..b5a37bf78 100644 --- a/environments/common/inventory/group_vars/builder/defaults.yml +++ b/environments/common/inventory/group_vars/builder/defaults.yml @@ -16,3 +16,4 @@ opensearch_state: stopped # avoid writing config+certs+db into image cuda_persistenced_state: stopped # probably don't have GPU in Packer build VMs firewalld_enabled: false # dnf install of firewalld enables it firewalld_state: stopped +appliances_validate: false