Skip to content
Snippets Groups Projects
Commit 0a5662aa authored by Milos Zdravkovic's avatar Milos Zdravkovic
Browse files

Replace import with include/block

parent 848c0851
No related branches found
No related tags found
No related merge requests found
Pipeline #90310 failed
......@@ -5,42 +5,45 @@
# playbook in order to introduce the opid_dir variable
# and avoid it's use all over the place.
# Because ansible.builtin.assemble works with a single directory
- name: Create a subdirectory for the assembled output
ansible.builtin.file:
path: "/var/tmp/ansible_run_{{ opid }}/assembled/"
state: directory
mode: '0755'
- name: Locally-delegated assemble block
delegate_to: localhost
block:
# Because ansible.builtin.assemble works with a single directory
- name: Create a subdirectory for the assembled output
ansible.builtin.file:
path: "/var/tmp/ansible_run_{{ opid }}/assembled/"
state: directory
mode: '0755'
# Enumeration prefix is needed to impact the order of assembly
- name: Copy Nokia SR OS header for assembly
ansible.builtin.copy:
src: "{{ vendor }}/header"
dest: "/var/tmp/ansible_run_{{ opid }}/assembled/00_header"
# Enumeration prefix is needed to impact the order of assembly
- name: Copy Nokia SR OS header for assembly
ansible.builtin.copy:
src: "{{ vendor }}/header"
dest: "/var/tmp/ansible_run_{{ opid }}/assembled/00_header"
# Enumeration prefix is needed to impact the order of assembly
- name: Copy Nokia SR OS footer for assembly
ansible.builtin.copy:
src: "{{ vendor }}/footer"
dest: "/var/tmp/ansible_run_{{ opid }}/assembled/02_footer"
# Enumeration prefix is needed to impact the order of assembly
- name: Assemble body of the config
ansible.builtin.assemble:
src: "/var/tmp/ansible_run_{{ opid }}/"
dest: "/var/tmp/ansible_run_{{ opid }}/assembled/01-body"
# Use the enumeration prefixes to assemble fragments in the right order
- name: Merge header, body and footer to get the final config
ansible.builtin.assemble:
src: "/var/tmp/ansible_run_{{ opid }}/assembled"
dest: "/var/tmp/ansible_run_{{ opid }}/assembled/for_deployment"
- name: Clean up the fragments
ansible.builtin.file:
path: "{{ item }}"
state: absent
mode: '0755'
with_fileglob:
# Enumeration prefix is needed to impact the order of assembly
- name: Copy Nokia SR OS footer for assembly
ansible.builtin.copy:
src: "{{ vendor }}/footer"
dest: "/var/tmp/ansible_run_{{ opid }}/assembled/02_footer"
# Enumeration prefix is needed to impact the order of assembly
- name: Assemble body of the config
ansible.builtin.assemble:
src: "/var/tmp/ansible_run_{{ opid }}/"
dest: "/var/tmp/ansible_run_{{ opid }}/assembled/01-body"
# Use the enumeration prefixes to assemble fragments in the right order
- name: Merge header, body and footer to get the final config
ansible.builtin.assemble:
src: "/var/tmp/ansible_run_{{ opid }}/assembled"
dest: "/var/tmp/ansible_run_{{ opid }}/assembled/for_deployment"
- name: Clean up the fragments
ansible.builtin.file:
path: "{{ item }}"
state: absent
mode: '0755'
with_fileglob:
- "/var/tmp/ansible_run_{{ opid }}/assembled/0*"
......@@ -3,10 +3,10 @@
- name: Fetch access port info from the subscription
ansible.builtin.include_tasks: traverse_subscription.yml
# The "delegate_to" works as expected in conjuction with "import_tasks"
# The "delegate_to" works as expected in conjuction with "import_tasks".
# However, mixing "imports" with "includes" is not recommended.
- name: Assemble the config from fragments in previous roles
ansible.builtin.import_tasks: assemble_config.yml
delegate_to: localhost
ansible.builtin.include_tasks: assemble_config.yml
- name: Include set connection tasks
ansible.builtin.include_tasks: connection_tasks.yml
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment