# Copyright 2021 Dell Inc. or its subsidiaries. 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. --- # Deleting the defaults - name: Delete machine credential awx.awx.tower_credential: name: "{{ default_credential }}" credential_type: "{{ default_credential_type }}" state: absent tower_config_file: "~/.tower_cli.cfg" - name: Delete job template awx.awx.tower_job_template: name: "{{ default_template }}" state: absent tower_config_file: "~/.tower_cli.cfg" - name: Delete project awx.awx.tower_project: name: "{{ default_project }}" state: absent tower_config_file: "~/.tower_cli.cfg" - name: Delete organization awx.awx.tower_organization: name: "{{ default_org }}" state: absent tower_config_file: "~/.tower_cli.cfg" # Configuration begins - name: Create organization awx.awx.tower_organization: name: "{{ awx_organization }}" description: "Name of organization using this product" state: present tower_config_file: "~/.tower_cli.cfg" - name: Create awx inventories awx.awx.tower_inventory: name: "{{ item.name }}" description: "{{ item.description }}" organization: "{{ awx_organization }}" state: present tower_config_file: "~/.tower_cli.cfg" loop: "{{ inventory_names }}" when: item.flag - name: Add groups to node_inventory awx.awx.tower_group: name: "{{ item.name }}" description: "{{ item.description }}" inventory: "node_inventory" state: present tower_config_file: "~/.tower_cli.cfg" loop: "{{ group_names }}" - name: Add project awx.awx.tower_project: name: "{{ project_name }}" description: "{{ project_description }}" organization: "{{ awx_organization }}" scm_type: manual local_path: "{{ role_path.split('/')[-4] }}" default_environment: "custom-awx-ee" state: present tower_config_file: "~/.tower_cli.cfg" - name: Add awx credentials awx.awx.tower_credential: name: "{{ item.name }}" organization: "{{ awx_organization }}" credential_type: "{{ item.type }}" inputs: username: "{{ item.username }}" password: "{{ item.password }}" state: present tower_config_file: "~/.tower_cli.cfg" loop: "{{ credential_details }}" changed_when: true when: item.flag - name: Create awx job templates awx.awx.tower_job_template: name: "{{ item.name }}" job_type: "run" organization: "{{ awx_organization }}" inventory: "{{ item.inventory }}" project: "{{ project_name }}" playbook: "{{ item.playbook }}" credentials: - "{{ item.credential }}" state: present tower_config_file: "~/.tower_cli.cfg" loop: "{{ job_template_details }}" when: item.flag - name: Create deploy_omnia_template awx.awx.tower_job_template: name: "{{ item.name }}" job_type: "run" organization: "{{ awx_organization }}" inventory: "{{ item.inventory }}" project: "{{ project_name }}" playbook: "{{ item.playbook }}" credentials: - "{{ item.credential }}" ask_skip_tags_on_launch: true state: present tower_config_file: "~/.tower_cli.cfg" loop: "{{ deploy_omnia_details }}" - name: Build a schedule for idrac job template awx.awx.tower_schedule: name: "{{ item.name }}" unified_job_template: "{{ item.template }}" rrule: "{{ schedule_rule }}" state: present tower_config_file: "~/.tower_cli.cfg" register: result loop: "{{ scheduled_templates}}"