Skip to content

Use environment hooks when building "fat" image #255

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions ansible/fatimage.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
# Builder version of site.yml just installing binaries

- name: Run pre.yml hook
vars:
appliances_environment_root: "{{ lookup('env', 'APPLIANCES_ENVIRONMENT_ROOT') }}"
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: bootstrap.yml

- name: Run post-bootstrap.yml hook
vars:
appliances_environment_root: "{{ lookup('env', 'APPLIANCES_ENVIRONMENT_ROOT') }}"
hook_path: "{{ appliances_environment_root }}/hooks/post-bootstrap.yml"
import_playbook: "{{ hook_path if hook_path | exists else 'noop.yml' }}"
when: hook_path | exists

- hosts: builder
become: yes
gather_facts: no
Expand Down Expand Up @@ -118,6 +132,17 @@

# - import_playbook: iam.yml - nothing to do

- name: Run post.yml hook
vars:
appliances_environment_root: "{{ lookup('env', 'APPLIANCES_ENVIRONMENT_ROOT') }}"
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
gather_facts: no
tasks:
- name: Cleanup image
import_tasks: cleanup.yml

Expand Down
2 changes: 1 addition & 1 deletion environments/.stackhpc/hooks/pre.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- hosts: control
- hosts: control:!builder
become: yes
gather_facts: false
tasks:
Expand Down
2 changes: 1 addition & 1 deletion packer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Building an environment-specific compute node image will[^1] require a cluster t
- Build images using the variable definition file:

cd packer
PACKER_LOG=1 /usr/bin/packer build -except openstack.fatimage --on-error=ask -var-file=$PKR_VAR_environment_root/builder.pkrvars.hcl openstack.pkr.hcl
PACKER_LOG=1 /usr/bin/packer build -except openstack.openhpc --on-error=ask -var-file=$PKR_VAR_environment_root/builder.pkrvars.hcl openstack.pkr.hcl

Note the builder VMs are added to the `builder` group to differentiate them from "real" nodes - see developer notes below.

Expand Down