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 @@ ...@@ -5,42 +5,45 @@
# playbook in order to introduce the opid_dir variable # playbook in order to introduce the opid_dir variable
# and avoid it's use all over the place. # and avoid it's use all over the place.
# Because ansible.builtin.assemble works with a single directory - name: Locally-delegated assemble block
- name: Create a subdirectory for the assembled output delegate_to: localhost
ansible.builtin.file: block:
path: "/var/tmp/ansible_run_{{ opid }}/assembled/" # Because ansible.builtin.assemble works with a single directory
state: directory - name: Create a subdirectory for the assembled output
mode: '0755' 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 # Enumeration prefix is needed to impact the order of assembly
- name: Copy Nokia SR OS header for assembly - name: Copy Nokia SR OS footer for assembly
ansible.builtin.copy: ansible.builtin.copy:
src: "{{ vendor }}/header" src: "{{ vendor }}/footer"
dest: "/var/tmp/ansible_run_{{ opid }}/assembled/00_header" dest: "/var/tmp/ansible_run_{{ opid }}/assembled/02_footer"
# Enumeration prefix is needed to impact the order of assembly # Enumeration prefix is needed to impact the order of assembly
- name: Copy Nokia SR OS footer for assembly - name: Assemble body of the config
ansible.builtin.copy: ansible.builtin.assemble:
src: "{{ vendor }}/footer" src: "/var/tmp/ansible_run_{{ opid }}/"
dest: "/var/tmp/ansible_run_{{ opid }}/assembled/02_footer" dest: "/var/tmp/ansible_run_{{ opid }}/assembled/01-body"
# Enumeration prefix is needed to impact the order of assembly # Use the enumeration prefixes to assemble fragments in the right order
- name: Assemble body of the config - name: Merge header, body and footer to get the final config
ansible.builtin.assemble: ansible.builtin.assemble:
src: "/var/tmp/ansible_run_{{ opid }}/" src: "/var/tmp/ansible_run_{{ opid }}/assembled"
dest: "/var/tmp/ansible_run_{{ opid }}/assembled/01-body" dest: "/var/tmp/ansible_run_{{ opid }}/assembled/for_deployment"
# Use the enumeration prefixes to assemble fragments in the right order - name: Clean up the fragments
- name: Merge header, body and footer to get the final config ansible.builtin.file:
ansible.builtin.assemble: path: "{{ item }}"
src: "/var/tmp/ansible_run_{{ opid }}/assembled" state: absent
dest: "/var/tmp/ansible_run_{{ opid }}/assembled/for_deployment" mode: '0755'
with_fileglob:
- name: Clean up the fragments
ansible.builtin.file:
path: "{{ item }}"
state: absent
mode: '0755'
with_fileglob:
- "/var/tmp/ansible_run_{{ opid }}/assembled/0*" - "/var/tmp/ansible_run_{{ opid }}/assembled/0*"
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
- name: Fetch access port info from the subscription - name: Fetch access port info from the subscription
ansible.builtin.include_tasks: traverse_subscription.yml 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 - name: Assemble the config from fragments in previous roles
ansible.builtin.import_tasks: assemble_config.yml ansible.builtin.include_tasks: assemble_config.yml
delegate_to: localhost
- name: Include set connection tasks - name: Include set connection tasks
ansible.builtin.include_tasks: connection_tasks.yml 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