--- # Copyright 2019 Red Hat, Inc. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. - name: Download config connection: "{{ (tripleo_target_host is defined) | ternary('ssh', 'local') }}" hosts: "{{ tripleo_target_host | default('localhost') }}" remote_user: "{{ tripleo_target_user | default(lookup('env', 'USER')) }}" gather_facts: "{{ (tripleo_target_host is defined) | ternary(true, false) }}" any_errors_fatal: true vars: plan: overcloud ssh_network: ctlplane ansible_ssh_user: tripleo-admin ansible_ssh_private_key_file: /home/stack/.ssh/id_rsa python_interpreter: null config_type: null preserve_config: true tasks: - name: Set output_dir set_fact: output_dir: "{{ lookup('env', 'HOME')~'/config-download'}}" when: output_dir is not defined - name: Set work_dir set_fact: work_dir: "{{ output_dir ~ '/' ~ plan }}" - name: Clean work_dir file: path: "{{ work_dir }}" state: absent when: not preserve_config | bool - name: Create config dir if does not exist file: path: "{{ work_dir }}" state: directory - name: Download config tripleo_config_download: plan: "{{ plan }}" work_dir: "{{ work_dir }}" download: true config_type: "{{ config_type }}" - name: Generate ansible inventory tripleo_generate_ansible_inventory: plan: "{{ plan }}" work_dir: "{{ work_dir }}" ssh_network: "{{ ssh_network }}" ansible_ssh_user: "{{ ansible_ssh_user }}" ansible_python_interpreter: "{{ python_interpreter }}" ansible_ssh_private_key_file: "{{ ansible_ssh_private_key_file }}" when: inventory_path is not defined or inventory_path != None # TODO(mwhahaha): switch tripleo_generate_ansible_inventory to do this # when we've nuked all the tripleo-ansible-inventory.yaml everywhere - name: Copy inventory to AnsibleRunner location block: - name: Create inventory directory ansible.builtin.file: path: "{{ output_dir ~ '/' ~ plan }}/inventory" state: directory mode: 0700 - name: Copy generated inventory ansible.builtin.copy: src: "{{ work_dir }}/tripleo-ansible-inventory.yaml" dest: "{{work_dir }}/inventory/tripleo" remote_src: true