--- # Purpose of this playbook: # This playbook deploy OSP 17.1 on previously created # infra for adoption. The main goal of this playbook # is to be called as a standalone piece of a bigger # job, mostly in the adoption context. # # You would typically run this playbook after the # "create-infra.yml" - name: Deploy 17.1 for adoption hosts: 'localhost' gather_facts: true vars: cifmw_basedir: "{{ ansible_user_dir }}/ci-framework-data" _adoption_source_scenario_file: >- {{ [cifmw_adoption_source_scenario_path, cifmw_architecture_scenario ~ '.yaml'] | path_join }} _target_host: "{{ cifmw_target_host | default('localhost') }}" tasks: - name: Inherit from parent scenarios if needed ansible.builtin.include_tasks: file: "ci/playbooks/tasks/inherit_parent_scenario.yml" - name: Ensure networking data is loaded ansible.builtin.include_role: name: networking_mapper tasks_from: load_env_definition.yml apply: delegate_to: "{{ _target_host }}" - name: Load source adoption scenario ansible.builtin.include_vars: file: "{{ _adoption_source_scenario_file }}" name: cifmw_adoption_osp_deploy_scenario - name: Gather ansible_user_id from {{ _target_host }} delegate_to: "{{ _target_host }}" ansible.builtin.setup: gather_subset: - user_id - user_dir - name: Read inventory groups delegate_to: "{{ _target_host }}" ansible.builtin.find: paths: "{{ ansible_user_dir }}/ci-framework-data/reproducer-inventory/" file_type: file patterns: '*.yml,*.yaml' register: "_all_groups" - name: Read groups inventory delegate_to: "{{ _target_host }}" ansible.builtin.slurp: path: "{{ item.path }}" register: _reproducer_inventory_files loop: "{{ _all_groups.files }}" - name: Set groups fact when: "'all' != _group_name" vars: _content: "{{ _inventory_file.content | b64decode | from_yaml }}" _group_name: "{{ _content | list | first }}" _nodes: "{{ _content[_group_name]['hosts'].keys() }}" _group_nodes: >- {%- set group = {} -%} {%- set _ = group.update({_group_name: _nodes}) -%} {{ group }} ansible.builtin.set_fact: _vm_groups: >- {{ _vm_groups | default({}) | combine(_group_nodes) }} loop: "{{ _reproducer_inventory_files.results }}" loop_control: loop_var: "_inventory_file" - name: Gather ansible_user_id from playbook target for hooks ansible.builtin.setup: gather_subset: - user_id - user_dir - name: Ensure parameters folder exists ansible.builtin.file: path: "{{ cifmw_basedir }}/artifacts/parameters" state: "directory" mode: "0755" - name: Save variables for use with hooks vars: _content: cifmw_adoption_osp_deploy_ntp_server: "{{ cifmw_adoption_osp_deploy_ntp_server }}" cifmw_adoption_source_scenario_path: "{{ cifmw_adoption_source_scenario_path }}" cifmw_adoption_osp_deploy_scenario: "{{ cifmw_adoption_osp_deploy_scenario }}" _vm_groups: "{{ _vm_groups }}" ansible.builtin.copy: dest: "{{ cifmw_basedir }}/artifacts/parameters/adoption_osp.yml" content: "{{ _content | to_nice_yaml }}" mode: "0644" - name: Set inventory_file for localhost to use with hooks ansible.builtin.set_fact: inventory_file: "{{ hostvars[_target_host]['inventory_file'] }}" - name: Deploy source osp environment ansible.builtin.import_role: name: "adoption_osp_deploy"