diff --git a/geant/gap_ansible/roles/deploy_service_config/tasks/assemble_config.yml b/geant/gap_ansible/roles/deploy_service_config/tasks/assemble_config.yml index 4105b2146dcffe3ae42b5c9a8b3fb4dad12fd00c..4196066de252cdd7b5250396e3c1fd0479ce51d8 100644 --- a/geant/gap_ansible/roles/deploy_service_config/tasks/assemble_config.yml +++ b/geant/gap_ansible/roles/deploy_service_config/tasks/assemble_config.yml @@ -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*" diff --git a/geant/gap_ansible/roles/deploy_service_config/tasks/main.yml b/geant/gap_ansible/roles/deploy_service_config/tasks/main.yml index 3de8126848fad63d041b76c16ca730b2eb562319..0a7d33773192af201f548ac1ebffa474a3d97ba2 100644 --- a/geant/gap_ansible/roles/deploy_service_config/tasks/main.yml +++ b/geant/gap_ansible/roles/deploy_service_config/tasks/main.yml @@ -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