cleaned up linting and added AAP on Code ready

This commit is contained in:
chadmf
2021-12-06 16:01:14 -06:00
parent a12658cbcc
commit 12f51112ab
135 changed files with 724 additions and 403 deletions

View File

@@ -0,0 +1,14 @@
---
- name: add aws credential
tower_credential:
name: aws_credential
description: AWS Credential
organization: "{{ vars[demo].project.organization }}"
state: present
kind: aws
username: "{{ my_access_key }}"
password: "{{ my_secret_key }}"
tower_username: "{{ my_tower_username }}"
tower_password: "{{ my_tower_password }}"
tower_host: "{{ my_tower_host }}"
validate_certs: false

View File

@@ -0,0 +1,17 @@
---
- name: add azure credential
awx.awx.credential:
name: azure_credential
description: Azure Service Principle
organization: "Default"
state: present
credential_type: Microsoft Azure Resource Manager
inputs:
subscription: "{{ my_subscription }}"
tenant: "{{ my_tenant }}"
client: "{{ my_client }}"
secret: "{{ my_secret }}"
controller_username: "{{ my_controller_username }}"
controller_password: "{{ my_controller_password }}"
controller_host: "{{ my_controller_host }}"
validate_certs: false

View File

@@ -0,0 +1,74 @@
---
- name: add tower project
awx.awx.tower_project:
name: "{{ job_template_definitions[demo].project.name }}"
description: "{{ job_template_definitions[demo].project.description }}"
organization: "{{ job_template_definitions[demo].project.organization }}"
scm_type: "{{ job_template_definitions[demo].project.scm_type }}"
scm_url: "{{ job_template_definitions[demo].project.scm_url }}"
tower_username: "{{ my_tower_username }}"
tower_password: "{{ my_tower_password }}"
tower_host: "{{ my_tower_host }}"
validate_certs: false
- name: show values
debug:
msg:
- "name: {{ job_template_definitions[demo].name }}"
- "description: {{ job_template_definitions[demo].description }}"
- "job_type: {{ job_template_definitions[demo].job_type }}"
- "inventory: {{ job_template_definitions[demo].inventory }}"
- "project: {{ job_template_definitions[demo].project.name }}"
- "playbook: {{ job_template_definitions[demo].playbook }}"
- "execution_environment: {{ job_template_definitions[demo].execution_environment | default('Default execution environment') }}"
- "fact_caching_enabled: {{ job_template_definitions[demo].fact_caching_enabled | default('false') }}"
- "credential: {{ job_template_definitions[demo].credential }}"
- "survey_enabled: {{ job_template_definitions[demo].survey_enabled | default('false') }}"
- name: add single job template without survey
awx.awx.tower_job_template:
name: "{{ job_template_definitions[demo].name }}"
description: "{{ job_template_definitions[demo].description }}"
job_type: "{{ job_template_definitions[demo].job_type }}"
inventory: "{{ job_template_definitions[demo].inventory }}"
project: "{{ job_template_definitions[demo].project.name }}"
playbook: "{{ job_template_definitions[demo].playbook }}"
execution_environment: "{{ job_template_definitions[demo].execution_environment | default('Default execution environment') }}"
fact_caching_enabled: "{{ job_template_definitions[demo].fact_caching_enabled | default('false') }}"
credential: "{{ job_template_definitions[demo].credential }}"
survey_enabled: "{{ job_template_definitions[demo].survey_enabled }}"
tower_username: "{{ my_tower_username }}"
tower_password: "{{ my_tower_password }}"
tower_host: "{{ my_tower_host }}"
validate_certs: false
when:
- workshop_type in job_template_definitions[demo].workshop_type
- not job_template_definitions[demo].survey_enabled
register: add_job_template
until: add_job_template is not failed
retries: 5
- name: add single job template with survey
awx.awx.tower_job_template:
name: "{{ job_template_definitions[demo].name }}"
description: "{{ job_template_definitions[demo].description }}"
job_type: "{{ job_template_definitions[demo].job_type }}"
inventory: "{{ job_template_definitions[demo].inventory }}"
project: "{{ job_template_definitions[demo].project.name }}"
playbook: "{{ job_template_definitions[demo].playbook }}"
execution_environment: "{{ job_template_definitions[demo].execution_environment | default('Default execution environment') }}"
fact_caching_enabled: "{{ job_template_definitions[demo].fact_caching_enabled | default('false') }}"
credential: "{{ job_template_definitions[demo].credential }}"
survey_enabled: "{{ job_template_definitions[demo].survey_enabled }}"
survey_spec: "{{ job_template_definitions[demo].survey_spec }}"
tower_username: "{{ my_tower_username }}"
tower_password: "{{ my_tower_password }}"
tower_host: "{{ my_tower_host }}"
validate_certs: false
when:
- workshop_type in job_template_definitions[demo].workshop_type
- job_template_definitions[demo].survey_enabled
register: add_job_template
until: add_job_template is not failed
retries: 5

View File

@@ -0,0 +1,76 @@
---
- name: installing demo
debug:
msg: "installing demo: {{item}}"
- name: block for job template loop
block:
- name: "add tower project job_template_loop.yml"
awx.awx.tower_project:
name: "{{ item.value.project.name }}"
description: "{{ item.value.project.description }}"
organization: "{{ item.value.project.organization }}"
scm_type: "{{ item.value.project.scm_type }}"
scm_url: "{{ item.value.project.scm_url }}"
tower_username: "{{ my_tower_username }}"
tower_password: "{{ my_tower_password }}"
tower_host: "{{ my_tower_host }}"
validate_certs: false
when:
- workshop_type in item.value.workshop_type
- name: "add job template {{ item.value.name }} without survey job_template_loop.yml"
awx.awx.tower_job_template:
name: "{{ item.value.name }}"
description: "{{ item.value.description }}"
job_type: "{{ item.value.job_type }}"
inventory: "{{ item.value.inventory }}"
project: "{{ item.value.project.name }}"
playbook: "{{ item.value.playbook }}"
execution_environment: "{{ item.value.execution_environment | default('Default execution environment') }}"
fact_caching_enabled: "{{ item.value.fact_caching_enabled | default('false') }}"
credential: "{{ item.value.credential }}"
survey_enabled: "{{ item.value.survey_enabled }}"
tower_username: "{{ my_tower_username }}"
tower_password: "{{ my_tower_password }}"
tower_host: "{{ my_tower_host }}"
validate_certs: false
when:
- workshop_type in item.value.workshop_type
- not item.value.survey_enabled
register: add_project
until: add_project is not failed
retries: 5
- name: "add job template {{ item.value.name }} with survey"
awx.awx.tower_job_template:
name: "{{ item.value.name }}"
description: "{{ item.value.description }}"
job_type: "{{ item.value.job_type }}"
inventory: "{{ item.value.inventory }}"
project: "{{ item.value.project.name }}"
playbook: "{{ item.value.playbook }}"
execution_environment: "{{ item.value.execution_environment | default('Default execution environment') }}"
fact_caching_enabled: "{{ item.value.fact_caching_enabled | default('false') }}"
credential: "{{ item.value.credential }}"
survey_enabled: "{{ item.value.survey_enabled }}"
survey_spec: "{{ item.value.survey_spec }}"
tower_username: "{{ my_tower_username }}"
tower_password: "{{ my_tower_password }}"
tower_host: "{{ my_tower_host }}"
validate_certs: false
when:
- workshop_type in item.value.workshop_type
- item.value.survey_enabled
register: add_project
until: add_project is not failed
retries: 5
when:
- item.value.workflow is not defined or not item.value.workflow
- name: install workflow inside loop (workflow)
include_tasks: workflow_loop.yml
when:
- item.value.workflow is defined
- item.value.workflow
- workshop_type in item.value.workshop_type

View File

@@ -0,0 +1,9 @@
---
- name: include all demo vars from install_demo roll
include_vars:
dir: "vars"
name: job_template_definitions
- name: will load vars
debug:
msg: "variables loaded from install_demo role into job_template_definitions"

View File

@@ -0,0 +1,48 @@
---
- name: explicitly load vars under a subkey for reliable access
include_tasks: load_vars.yml
- name: set facts from role vars
set_fact:
demo_list: "{{ job_template_definitions|dict2items|map(attribute='key')|list }}"
full_demo_info: "{{ job_template_definitions|dict2items }}"
- name: provide info to terminal window
debug:
msg:
- "install {{ demo }} on {{ my_tower_host }}"
- "total demos: {{ demo_list | length }}"
- "available demos are: {{ demo_list }}"
- name: make sure demo is a valid demo
assert:
that:
- demo is defined
- demo in demo_list or demo == "all"
msg:
- "demo must be defined and be one of: {{ demo_list }}"
- "full list can be found on https://github.com/ansible/product-demos"
- name: setup public cloud credentials
include_tasks: "{{item}}"
with_first_found:
- "{{role_path}}/tasks/{{public_cloud}}.yml"
- "{{role_path}}/tasks/unsupported_cloud.yml"
- name: install all job templates
include_tasks: job_template_loop.yml
loop: "{{ full_demo_info }}"
when: demo == "all"
- name: install single job template
include_tasks: job_template.yml
when:
- demo != "all"
- job_template_definitions[demo].workflow is not defined or not job_template_definitions[demo].workflow
- name: install single workflow
include_tasks: workflow.yml
when:
- demo != "all"
- job_template_definitions[demo].workflow is defined
- job_template_definitions[demo].workflow

View File

@@ -0,0 +1,16 @@
- name: public cloud not supported
debug:
msg: "there is no public cloud credentials for this install, installing dummy creds"
- name: add azure credential
awx.awx.tower_credential:
name: azure_credential
description: Azure Service Principle
organization: "Default"
state: present
kind: azure_rm
subscription: "please replace me"
tower_username: "{{ my_tower_username }}"
tower_password: "{{ my_tower_password }}"
tower_host: "{{ my_tower_host }}"
validate_certs: false

View File

@@ -0,0 +1,6 @@
---
# these tasks will install a workflow
- name: "install all job templates in relation to workflow {{ job_template_definitions[demo].name }}"
include_tasks: add_job_template.yml
loop: "{{ job_template_definitions[demo].job_templates|dict2items }}"

View File

@@ -0,0 +1,4 @@
---
- name: "INSIDE LOOP - install all job templates in relation to workflow {{ item.value.name }}"
include_tasks: job_template_loop.yml
loop: "{{ item.value.job_templates|dict2items }}"