diff --git a/docs/contribute.md b/docs/contribute.md index 0d663a2..9821721 100644 --- a/docs/contribute.md +++ b/docs/contribute.md @@ -2,6 +2,12 @@ This project is **not** currently taking PRs (pull requests) or code contributions. This is currently a work in progress and not at a point that would make sense to take contributions. Please try to make PRs into [ansible-examples](https://github.com/ansible/ansible-examples) if you want to showcase Ansible Playbooks or roles. +# Converting Existing Workflows into ephemeral demos + +There is no way in the Ansible Tower API to access the workflow schema at this time (March 2020). Please refer to the docs and use the awx-cli/tower-cli command to export existing Workflow schema: [https://github.com/ansible/tower-cli/blob/master/docs/source/cli_ref/usage/WORKFLOWS.rst](documentation). + +The Workflow schema can be automated by using the [tower_workflow_template](https://docs.ansible.com/ansible/latest/modules/tower_workflow_template_module.html#parameter-schema) module to load Ansible Tower with an entire Workflow. + # Going Further The following links will be helpful if you want to contribute code to the Ansible Workshops project, or any Ansible project: diff --git a/playbooks/group_vars/all/20_f5_bigip_workflow.yml b/playbooks/group_vars/all/20_f5_bigip_workflow.yml new file mode 100644 index 0000000..0c79ab3 --- /dev/null +++ b/playbooks/group_vars/all/20_f5_bigip_workflow.yml @@ -0,0 +1,82 @@ +--- +f5_bigip_workflow: + workflow: true + author: "Sean Cavanaugh" + name: "WORKFLOW - F5 BIG-IP" + description: 'Workflow for F5 BIG-IP to setup a VIP (Virtual IP) load balancer between two RHEL webservers' + organization: "Default" + workshop_type: + - f5 + schema: + - job_template: "F5 - add nodes" + success: + - job_template: "F5 - add pool" + success: + - job_template: "F5 - add pool members" + success: + - job_template: "F5 - add virtual server" + job_templates: + f5_add_nodes: + name: "F5 - add nodes" + description: "add webserver nodes into F5 BIG-IP" + job_type: "run" + inventory: "Workshop Inventory" + playbook: "exercises/ansible_f5/1.2-add-node/bigip-node.yml" + credential: "Workshop Credential" + survey_enabled: no + project: + name: "Ansible Workshops Project" + description: "official workshops from Ansible" + organization: "Default" + scm_type: git + scm_url: "https://github.com/ansible/workshops" + workshop_type: + - f5 + f5_add_pool: + name: "F5 - add pool" + description: "add webserver nodes into F5 BIG-IP" + job_type: "run" + inventory: "Workshop Inventory" + playbook: "exercises/ansible_f5/1.3-add-pool/bigip-pool.yml" + credential: "Workshop Credential" + survey_enabled: no + project: + name: "Ansible Workshops Project" + description: "official workshops from Ansible" + organization: "Default" + scm_type: git + scm_url: "https://github.com/ansible/workshops" + workshop_type: + - f5 + f5_add_pool_members: + name: "F5 - add pool members" + description: "add webserver nodes into pool" + job_type: "run" + inventory: "Workshop Inventory" + playbook: "exercises/ansible_f5/1.4-add-pool-members/bigip-pool-members.yml" + credential: "Workshop Credential" + survey_enabled: no + project: + name: "Ansible Workshops Project" + description: "official workshops from Ansible" + organization: "Default" + scm_type: git + scm_url: "https://github.com/ansible/workshops" + workshop_type: + - f5 + f5_add_vip: + name: "F5 - add virtual server" + description: "create VIP and add pool to virtual server" + job_type: "run" + inventory: "Workshop Inventory" + playbook: "exercises/ansible_f5/1.5-add-virtual-server/bigip-virtual-server.yml" + credential: "Workshop Credential" + survey_enabled: no + project: + name: "Ansible Workshops Project" + description: "official workshops from Ansible" + organization: "Default" + scm_type: git + scm_url: "https://github.com/ansible/workshops" + workshop_type: + - f5 diff --git a/roles/install_demo/tasks/add_job_template.yml b/roles/install_demo/tasks/add_job_template.yml index 5d71c30..1f0c01d 100644 --- a/roles/install_demo/tasks/add_job_template.yml +++ b/roles/install_demo/tasks/add_job_template.yml @@ -1,3 +1,4 @@ +--- - name: add tower project tower_project: name: "{{item.value.project.name}}" diff --git a/roles/install_demo/tasks/main.yml b/roles/install_demo/tasks/main.yml index 3927073..de3427e 100644 --- a/roles/install_demo/tasks/main.yml +++ b/roles/install_demo/tasks/main.yml @@ -10,4 +10,13 @@ - name: install single job template include: single_job_template.yml - when: demo != "all" + when: + - demo != "all" + - hostvars[inventory_hostname][demo].workflow is undefined or not hostvars[inventory_hostname][demo].workflow + +- name: install single workflow + include: workflow.yml + when: + - demo != "all" + - hostvars[inventory_hostname][demo].workflow is defined + - hostvars[inventory_hostname][demo].workflow diff --git a/roles/install_demo/tasks/single_job_template.yml b/roles/install_demo/tasks/single_job_template.yml index f9737ff..81f55d0 100644 --- a/roles/install_demo/tasks/single_job_template.yml +++ b/roles/install_demo/tasks/single_job_template.yml @@ -1,3 +1,4 @@ +--- - name: add tower project tower_project: name: "{{hostvars.localhost[demo].project.name}}" @@ -26,7 +27,7 @@ tower_host: "{{my_tower_host}}" validate_certs: no when: - - workshop_type in item.value.workshop_type + - workshop_type in hostvars.localhost[demo].workshop_type - not hostvars.localhost[demo].survey_enabled - name: add single job template with survey @@ -46,5 +47,5 @@ tower_host: "{{my_tower_host}}" validate_certs: no when: - - workshop_type in item.value.workshop_type + - workshop_type in hostvars.localhost[demo].workshop_type - hostvars.localhost[demo].survey_enabled diff --git a/roles/install_demo/tasks/workflow.yml b/roles/install_demo/tasks/workflow.yml new file mode 100644 index 0000000..c1e21e5 --- /dev/null +++ b/roles/install_demo/tasks/workflow.yml @@ -0,0 +1,16 @@ +--- +#these tasks will install a workflow + +- name: install all job templates in relation to workflow + include: add_job_template.yml + loop: "{{hostvars[inventory_hostname][demo].job_templates|dict2items}}" + +- tower_workflow_template: + name: "{{hostvars[inventory_hostname][demo].name}}" + description: "{{hostvars[inventory_hostname][demo].description}}" + organization: "{{hostvars[inventory_hostname][demo].organization}}" + schema: "{{ hostvars[inventory_hostname][demo].schema}}" + tower_username: "{{my_tower_username}}" + tower_password: "{{my_tower_password}}" + tower_host: "{{my_tower_host}}" + validate_certs: no