From 1a8b702af3ec6d9fe139a606b22c64e3da76c12f Mon Sep 17 00:00:00 2001 From: Tom Page Date: Thu, 25 Jun 2020 15:08:13 +0100 Subject: [PATCH] remove archived role --- .../ansible_tower_genie_surveys/README.md | 261 ------------------ .../defaults/main.yml | 78 ------ .../ansible_tower_genie_surveys/meta/main.yml | 67 ----- .../tasks/build_job_template_survey.yml | 124 --------- .../tasks/build_survey_spec.yml | 129 --------- .../tasks/main.yml | 15 - .../vars/tower-secrets.yml | 2 - 7 files changed, 676 deletions(-) delete mode 100644 roles/archive/ansible_tower_genie_surveys/README.md delete mode 100644 roles/archive/ansible_tower_genie_surveys/defaults/main.yml delete mode 100644 roles/archive/ansible_tower_genie_surveys/meta/main.yml delete mode 100644 roles/archive/ansible_tower_genie_surveys/tasks/build_job_template_survey.yml delete mode 100644 roles/archive/ansible_tower_genie_surveys/tasks/build_survey_spec.yml delete mode 100644 roles/archive/ansible_tower_genie_surveys/tasks/main.yml delete mode 100644 roles/archive/ansible_tower_genie_surveys/vars/tower-secrets.yml diff --git a/roles/archive/ansible_tower_genie_surveys/README.md b/roles/archive/ansible_tower_genie_surveys/README.md deleted file mode 100644 index ef4fa3a12..000000000 --- a/roles/archive/ansible_tower_genie_surveys/README.md +++ /dev/null @@ -1,261 +0,0 @@ -# ansible_tower_genie_surveys -## Table of Contents -- [ansible_tower_genie_surveys](#ansible_tower_genie_surveys) - - [Table of Contents](#table-of-contents) - - [Description](#description) - - [Variables](#variables) - - [Variable `tower_surveys` Dictionary Specification](#variable-tower_surveys-dictionary-specification) - - [`survey` Dictionary](#survey-dictionary) - - [Common Keys for `survey` Dictionaries](#common-keys-for-survey-dictionaries) - - [Type float Keys](#type-float-keys) - - [Type integer Keys](#type-integer-keys) - - [Type multiselect Keys](#type-multiselect-keys) - - [Type multiplechoice Keys](#type-multiplechoice-keys) - - [Type password Keys](#type-password-keys) - - [Type textarea Keys](#type-textarea-keys) - - [Type text Keys](#type-text-keys) - - [Playbook Examples](#playbook-examples) - - [Normal Role Definition in Play](#normal-role-definition-in-play) - - [Include Role in Task](#include-role-in-task) - - [License](#license) - - [Author](#author) - -## Description -An Ansible Role to deploy and ensure job template surveys are in a desired state in Ansible Tower. -## Variables -|Variable Name|Default Value|Required|Description|Type| -|---|:---:|:---:|---|:---:| -|`tower_hostname`|""|yes|URL to the Ansible Tower Server.|string| -|`validate_certs`|False|no|Whether or not to validate the Ansible Tower Server's SSL certificate.|boolean| -|`tower_secrets`|False|yes|Whether or not to include variables stored in vars/tower-secrets.yml. Set this value to `False` if you will be providing your sensitive values from elsewhere.|boolean| -|`tower_username`|""|yes|Admin User on the Ansible Tower Server.|string| -|`tower_password`|""|yes|Tower Admin User's password on the Ansible Tower Server. This should be stored in an Ansible Vault at vars/tower-secrets.yml or elsewhere and called from a parent playbook.|string| -|`tower_surveys`|[]|yes|Ansible Tower survey definitions|List of dictionaries| - -### Variable `tower_surveys` Dictionary Specification -The `tower_surveys` skeleton structure is as follows: -*Collapsed YAML:* -```yaml -tower_surveys: [{job_template_name: "", job_template_survey_enabled: True, survey: [{}]}] -``` -*Expanded YAML:* -```yaml -tower_surveys: - - job_template_name: "" - job_template_survey_enabled: True - survey: [{}] -``` - -|Key Name|Required|Description|Type| -|---|:---:|---|:---:| -|`job_template_name`|yes|Name of the Ansible Tower job template to operate on.|string| -|`job_template_survey_enabled`|yes|Whether or not to enable the survey on the job template.|boolean| -|`survey`|yes|The survey definition for the job template. Each dictionary in the list defines a field in the survey.|List of dictionaries.| - -#### `survey` Dictionary -Based on the type of survey field, different dictionary keys are required, which are described below. - -##### Common Keys for `survey` Dictionaries -These are valid for any of the "type" key values described in the next section. - -|Key Name|Required|Description|Type| -|---|:---:|---|---| -|`variable`|yes|The variable to map the end-user's survey response to when executing the job template.|string| -|`prompt`|yes|The survey field label that the end-user will see when executing the job template.|string| -|`type`|yes|The type of survey field to generate in the job template's survey. The value can be one of the following: float, integer, multiselect, multiplechoice, password, textarea, text|string| -|`description`|no|The survey field's description the end-user will see when executing the job template.|string| -|`default`|no|The survey field's default/pre-filled value that the end-user will see when executing the job template.|string (on type multiselect this is a list, and on type password this is not available because Ansible Tower stores the value encrypted and it becomes "$encrypted$" in the stored specification and unable to ensure the values match the desired state otherwise)| -|`required`|Whether or not the end-user is required to enter data into the survey field when executing the job template|boolean| - -##### Type float Keys -A numeric value with a floating decimal point. - -|Key Name|Required|Default Value|Description|Type| -|---|:---:|:---:|---|---| -|min|no|0|Minimum value accepted|float| -|max|no|100|Maximum value accepted|float| - -##### Type integer Keys -An integer value. - -|Key Name|Required|Default Value|Description|Type| -|---|:---:|:---:|---|---| -|min|no|0|Minimum value accepted.|integer| -|max|no|100|Maximum value accepted.|integer| - -##### Type multiselect Keys -A multiple-choice multiple-select (Ansible Tower converts this to a list). - -|Key Name|Required|Default Value|Description|Type| -|---|:---:|:---:|---|---| -|choices|yes|n/a|List of choices to present the end-user with when executing the job template|list| - -##### Type multiplechoice Keys -A multiple-choice single-select (Ansible Tower converts this to a string). - -|Key Name|Required|Default Value|Description|Type| -|---|:---:|:---:|---|---| -|choices|yes|n/a|List of choices to present the end-user with when executing the job template.|list| - -##### Type password Keys -A password that Ansible Tower encrypts. It is handled differently than a text type. - -|Key Name|Required|Default Value|Description|Type| -|---|:---:|:---:|---|---| -|min|no|0|Minimum number of characters accepted in the survey field.|integer| -|max|no|32|Maximum number of characters accepted in the survey field.|integer| - -##### Type textarea Keys -A field to enter multi-lined text. - -|Key Name|Required|Default Value|Description|Type| -|---|:---:|:---:|---|---| -|min|no|0|Minimum number of characters accepted in the survey field.|integer| -|max|no|4096|Maximum number of characters accepted in the survey field.|integer| - -##### Type text Keys -A field to enter text (string). - -|Key Name|Required|Default Value|Description|Type| -|---|:---:|:---:|---|---| -|min|no|0|Minimum number of characters accepted in the survey field.|integer| -|max|no|1024|Maximum number of characters accepted in the survey field.|integer| - -## Playbook Examples -### Normal Role Definition in Play -```yaml ---- -- name: "Ensure my surveys are created" - hosts: "localhost" - connection: "local" - vars_files: - - "vars/myvault.yml" - roles: - - role: "ansible_tower_genie_surveys" - tower_hostname: "https://mytower.mydomain.com" - validate_certs: false - tower_secrets: false - tower_username: "" - tower_password: "{{ vaulted_tower_pass }}" - tower_surveys: - - job_template_name: "My Job Template 1" - job_template_survey_enabled: True - survey: - - variable: "myfloatvar" - type: "float" - prompt: "Enter a float value between 4 and 10" - description: "A value to do some math with" - default: "6.5" - min: "4" - max: "10" - required: True - - variable: "mypetlist" - type: "multiselect" - prompt: "Select the kinds of pets you have" - choices: - - "dog" - - "cat" - - "fish" - - "bird" - - "hamster" - - "chinchilla" - default: - - "dog" - - "fish" - required: False - - variable: "petname" - type: "multiplechoice" - prompt: "What's your favorite pet name?" - description: "A list of pet names to choose from" - choices: - - "Fritz" - - "Ava" - - "Bob" - default: "Fritz" - required: True - - job_template_name: "My Job Template 2" - job_template_survey_enabled: False - survey: - - variable: "text1" - type: "text" - prompt: "Enter some text" - description: "A string to use in my playbook" - - variable: "my_pass" - type: "password" - prompt: "Enter the password to my application" - min: "10" - max: "25" -``` - -### Include Role in Task -```yaml ---- -- name: "Ensure my surveys are created" - hosts: "localhost" - connection: "local" - vars_files: - - "vars/myvault.yml" - tasks: - - name: "Build my job template surveys" - include_role: - name: "genie-survey" - vars: - tower_hostname: "https://mytower.mydomain.com" - validate_certs: false - tower_secrets: False - tower_username: "" - tower_password: "{{ vaulted_tower_pass }}" - tower_surveys: - - job_template_name: "My Job Template 1" - job_template_survey_enabled: True - survey: - - variable: "myfloatvar" - type: "float" - prompt: "Enter a float value between 4 and 10" - description: "A value to do some math with" - default: "6.5" - min: "4" - max: "10" - required: True - - variable: "mypetlist" - type: "multiselect" - prompt: "Select the kinds of pets you have" - choices: - - "dog" - - "cat" - - "fish" - - "bird" - - "hamster" - - "chinchilla" - default: - - "dog" - - "fish" - required: False - - variable: "petname" - type: "multiplechoice" - prompt: "What's your favorite pet name?" - description: "A list of pet names to choose from" - choices: - - "Fritz" - - "Ava" - - "Bob" - default: "Fritz" - required: True - - job_template_name: "My Job Template 2" - job_template_survey_enabled: False - survey: - - variable: "text1" - type: "text" - prompt: "Enter some text" - description: "A string to use in my playbook" - - variable: "my_pass" - type: "password" - prompt: "Enter the password to my application" - min: "10" - max: "25" -``` -## License -[MIT](LICENSE) - -## Author -[Andrew J. Huffman](https://github.com/ahuffman) diff --git a/roles/archive/ansible_tower_genie_surveys/defaults/main.yml b/roles/archive/ansible_tower_genie_surveys/defaults/main.yml deleted file mode 100644 index 291e7790b..000000000 --- a/roles/archive/ansible_tower_genie_surveys/defaults/main.yml +++ /dev/null @@ -1,78 +0,0 @@ ---- -tower_hostname: "" -validate_certs: false -tower_secrets: false -tower_username: "" -tower_password: "" # Put in a vault at vars/tower-secrets.yml when tower_secrets: True -tower_surveys: [] -# some examples: -# tower_surveys: -# - job_template_name: "testing" -# #job_template_survey_enabled: can be either true|false -# job_template_survey_enabled: true -# survey: -# #type: can be one of the following -# #float|integer|multiselect|multiplechoice|password|textarea|text -# #parameters for each type differ, see README.md for details -# - variable: "float1" -# prompt: "float1" -# type: "float" -# description: "my float 1" -# required: true -# - variable: "float2" -# type: "float" -# prompt: "float2" -# default: "5.0" -# required: false -# - variable: "int1" -# prompt: "int1" -# type: "integer" -# description: "whole number between 1 and 5" -# min: "1" -# max: "5" -# default: "1" -# required: true -# - variable: "multi1" -# prompt: "multi1" -# type: "multiselect" -# default: -# - "item1" -# - "item3" -# choices: -# - "item1" -# - "item2" -# - "item3" -# required: true -# - variable: "multi2" -# prompt: "multi2" -# type: "multiplechoice" -# default: "item3" -# choices: -# - "item1" -# - "item2" -# - "item3" -# required: false -# - variable: "area1" -# prompt: "area1" -# type: "textarea" -# description: "test textarea1" -# default: | -# some multi-line text -# to consider as a value -# required: true -# - variable: "area2" -# prompt: "area2" -# type: "textarea" -# default: "another\nway\nto\nprovide\ntext\nin\na\narea" -# required: true -# - variable: "text1" -# prompt: "text1" -# type: "text" -# default: "some text" -# required: false -# - variable: "pass1" -# prompt: "pass1" -# type: "password" -# max: "500" -# min: "10" -# required: true diff --git a/roles/archive/ansible_tower_genie_surveys/meta/main.yml b/roles/archive/ansible_tower_genie_surveys/meta/main.yml deleted file mode 100644 index e691ba48e..000000000 --- a/roles/archive/ansible_tower_genie_surveys/meta/main.yml +++ /dev/null @@ -1,67 +0,0 @@ ---- -galaxy_info: - role_name: "ansible_tower_genie_surveys" - author: "Andrew J. Huffman" - description: "An Ansible Role to deploy and ensure job template surveys are in a desired state in Ansible Tower." - company: "Red Hat" - - # If the issue tracker for your role is not on github, uncomment the - # next line and provide a value - # issue_tracker_url: http://example.com/issue/tracker - - # Some suggested licenses: - # - BSD (default) - # - MIT - # - GPLv2 - # - GPLv3 - # - Apache - # - CC-BY - license: "MIT" - - min_ansible_version: 2.5 - - # If this a Container Enabled role, provide the minimum Ansible Container version. - # min_ansible_container_version: - - # Optionally specify the branch Galaxy will use when accessing the GitHub - # repo for this role. During role install, if no tags are available, - # Galaxy will use this branch. During import Galaxy will access files on - # this branch. If Travis integration is configured, only notifications for this - # branch will be accepted. Otherwise, in all cases, the repo's default branch - # (usually master) will be used. - # github_branch: - - # - # platforms is a list of platforms, and each platform has a name and a list of versions. - # - platforms: - - name: "EL" - versions: - - "all" - # - name: Fedora - # versions: - # - all - # - 25 - # - name: SomePlatform - # versions: - # - all - # - 1.0 - # - 7 - # - 99.99 - - galaxy_tags: - - "ansibletower" - - "awx" - - "tower" - - "configuration" - - "surveys" - # List tags for your role here, one per line. A tag is a keyword that describes - # and categorizes the role. Users find roles by searching for tags. Be sure to - # remove the '[]' above, if you add tags to this list. - # - # NOTE: A tag is limited to a single word comprised of alphanumeric characters. - # Maximum 20 tags per role. - -dependencies: [] -# List your role dependencies here, one per line. Be sure to remove the '[]' above, -# if you add dependencies to this list. diff --git a/roles/archive/ansible_tower_genie_surveys/tasks/build_job_template_survey.yml b/roles/archive/ansible_tower_genie_surveys/tasks/build_job_template_survey.yml deleted file mode 100644 index c28a4d0d4..000000000 --- a/roles/archive/ansible_tower_genie_surveys/tasks/build_job_template_survey.yml +++ /dev/null @@ -1,124 +0,0 @@ ---- -- name: "Initialize empty Ansible Tower job template survey specification" - set_fact: - tower_survey: [] - -# Build survey spec for job template -- name: "Build Ansible Tower job template specification | {{ job_template.job_template_name }}" - include_tasks: "build_survey_spec.yml" - with_items: "{{ job_template.survey }}" - loop_control: - loop_var: "survey_field" - label: "{{ survey_field.variable }}" - when: "job_template.survey | length > 0" - -# Get job template id -- name: "Retrieve and set Ansible Tower job template ID" - block: - - name: "Retrieve Ansible Tower job template ID" - uri: - url: "{{ tower_hostname }}/api/v2/job_templates/" - user: "{{ tower_username }}" - password: "{{ tower_password }}" - force_basic_auth: True - method: "GET" - status_code: "200" - validate_certs: "{{ validate_certs }}" - register: "tower_job_templates" - changed_when: false - no_log: true - - - name: "Initialize Ansible Tower job template data" - set_fact: - job_template_id: "" - job_template_survey_enabled: "" - - - name: "Set Ansible Tower job template ID" - set_fact: - job_template_id: "{{ template.id }}" - job_template_survey_enabled: "{{ template.survey_enabled }}" - with_items: "{{ tower_job_templates.json.results }}" - loop_control: - loop_var: "template" - label: "{{ template.name }}" - when: "job_template.job_template_name == template.name" - - - name: "Could not find specified job template name in Ansible Tower" - fail: - msg: - - "Could not find specified job template name {{ job_template.job_template_name }}" - - "Please make sure the job template exists." - when: not job_template_id - -# Get current survey -- name: "Retrieve current Ansible Tower job template survey" - uri: - url: "{{ tower_hostname }}/api/v2/job_templates/{{ job_template_id }}/survey_spec/" - user: "{{ tower_username }}" - password: "{{ tower_password }}" - force_basic_auth: True - method: "GET" - status_code: "200" - validate_certs: "{{ validate_certs }}" - register: "tower_job_template_current_survey" - changed_when: false - no_log: true - -# Update survey spec when not in desired state if different than existing -- name: "Format Ansible Tower Survey" - set_fact: - tower_survey_formatted: {description: "", name: "", spec: "{{ tower_survey }}"} - -- name: "Update job template {{ job_template.job_template_name }}'s survey" - uri: - url: "{{ tower_hostname }}/api/v2/job_templates/{{ job_template_id }}/survey_spec/" - user: "{{ tower_username }}" - password: "{{ tower_password }}" - force_basic_auth: True - method: "POST" - body: "{{ tower_survey_formatted | to_json }}" - body_format: "json" - status_code: "200" - validate_certs: "{{ validate_certs }}" - register: "update_survey" - changed_when: 'update_survey.status == 200' - no_log: true - when: 'tower_survey_formatted != tower_job_template_current_survey.json' - -# Ensure survey is enabled -- name: "Ensure {{ job_template.job_template_name }}'s survey is enabled" - uri: - url: "{{ tower_hostname }}/api/v2/job_templates/{{ job_template_id }}/" - user: "{{ tower_username }}" - password: "{{ tower_password }}" - force_basic_auth: True - method: "PATCH" - body: '{"survey_enabled": true}' - body_format: "json" - status_code: "200" - validate_certs: "{{ validate_certs }}" - register: "enable_job_template_survey" - changed_when: 'enable_job_template_survey.status == 200' - no_log: true - when: - - 'job_template.job_template_survey_enabled' - - 'not job_template_survey_enabled' - -# Ensure survey is not enabled -- name: "Ensure {{ job_template.job_template_name }}'s survey is not enabled" - uri: - url: "{{ tower_hostname }}/api/v2/job_templates/{{ job_template_id }}/" - user: "{{ tower_username }}" - password: "{{ tower_password }}" - force_basic_auth: True - method: "PATCH" - body: '{"survey_enabled": false}' - body_format: "json" - status_code: "200" - validate_certs: "{{ validate_certs }}" - register: "disable_job_template_survey" - changed_when: 'disable_job_template_survey.status == 200' - no_log: true - when: - - 'not job_template.job_template_survey_enabled' - - 'job_template_survey_enabled' diff --git a/roles/archive/ansible_tower_genie_surveys/tasks/build_survey_spec.yml b/roles/archive/ansible_tower_genie_surveys/tasks/build_survey_spec.yml deleted file mode 100644 index a38661e7f..000000000 --- a/roles/archive/ansible_tower_genie_surveys/tasks/build_survey_spec.yml +++ /dev/null @@ -1,129 +0,0 @@ ---- -- name: "Unset temporary survey field variable" - set_fact: - add_survey_field: [] - -- name: "Add survey field | float" - set_fact: - add_survey_field: - [{ - question_description: "{{ survey_field.description | default('') }}", - min: "{{ survey_field.min | default('0') }}", - default: "{{ survey_field.default | default('') }}", - max: "{{ survey_field.max | default('100') }}", - required: "{{ survey_field.required }}", - choices: "", - new_question: true, - variable: "{{ survey_field.variable }}", - question_name: "{{ survey_field.prompt }}", - type: "float" - }] - when: 'survey_field.type == "float"' - - -- name: "Add survey field | integer" - set_fact: - add_survey_field: - [{ - question_description: "{{ survey_field.description | default('') }}", - min: "{{ survey_field.min | default('0') }}", - default: "{{ survey_field.default | default('') }}", - max: "{{ survey_field.max | default('100') }}", - required: "{{ survey_field.required }}", - choices: "", - new_question: true, - variable: "{{ survey_field.variable }}", - question_name: "{{ survey_field.prompt }}", - type: "integer" - }] - when: 'survey_field.type == "integer"' - -- name: "Add survey field | multiple-choice multiple-select" - set_fact: - add_survey_field: - [{ - question_description: "{{ survey_field.description | default('') }}", - min: null, - default: "{{ survey_field.default | join('\n') | default('') }}", - max: null, - required: "{{ survey_field.required }}", - choices: "{{ survey_field.choices | join('\n') }}", - new_question: true, - variable: "{{ survey_field.variable }}", - question_name: "{{ survey_field.prompt }}", - type: "multiselect" - }] - when: 'survey_field.type == "multiselect"' - -- name: "Add survey field | multiple-choice single-select" - set_fact: - add_survey_field: - [{ - question_description: "{{ survey_field.description | default('') }}", - min: null, - default: "{{ survey_field.default | default('') }}", - max: null, - required: "{{ survey_field.required }}", - choices: "{{ survey_field.choices | join('\n') }}", - new_question: true, - variable: "{{ survey_field.variable }}", - question_name: "{{ survey_field.prompt }}", - type: "multiplechoice" - }] - when: 'survey_field.type == "multiplechoice"' - -- name: "Add survey field | password" - set_fact: - add_survey_field: - [{ - question_description: "{{ survey_field.description | default('') }}", - min: "{{ survey_field.min | default('0') }}", - default: "", - max: "{{ survey_field.max | default('32') }}", - required: "{{ survey_field.required }}", - choices: "", - new_question: true, - variable: "{{ survey_field.variable }}", - question_name: "{{ survey_field.prompt }}", - type: "password" - }] - when: 'survey_field.type == "password"' - -- name: "Add survey field | text area" - set_fact: - add_survey_field: - [{ - question_description: "{{ survey_field.description | default('') }}", - min: "{{ survey_field.min | default('0') }}", - default: "{{ survey_field.default | default('') }}", - max: "{{ survey_field.max | default('4096') }}", - required: "{{ survey_field.required }}", - choices: "", - new_question: true, - variable: "{{ survey_field.variable }}", - question_name: "{{ survey_field.prompt }}", - type: "textarea" - }] - when: 'survey_field.type == "textarea"' - - -- name: "Add survey field | text" - set_fact: - add_survey_field: - [{ - question_description: "{{ survey_field.description | default('') }}", - min: "{{ survey_field.min | default('0') }}", - default: "{{ survey_field.default | default('') }}", - max: "{{ survey_field.max | default('1024') }}", - required: "{{ survey_field.required }}", - choices: "", - new_question: true, - variable: "{{ survey_field.variable }}", - question_name: "{{ survey_field.prompt }}", - type: "text" - }] - when: 'survey_field.type == "text"' - -- name: "Add survey field | {{ survey_field.variable }}" - set_fact: - tower_survey: "{{ tower_survey | union(add_survey_field) }}" diff --git a/roles/archive/ansible_tower_genie_surveys/tasks/main.yml b/roles/archive/ansible_tower_genie_surveys/tasks/main.yml deleted file mode 100644 index 249e5447c..000000000 --- a/roles/archive/ansible_tower_genie_surveys/tasks/main.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- -- name: "Bring in vaulted Ansible Tower secrets" - include_vars: "vars/tower-secrets.yml" - when: "tower_secrets" - no_log: true - -# Build survey spec for job template -- name: "Build Ansible Tower job template survey specification" - include_tasks: "build_job_template_survey.yml" - with_items: "{{ tower_surveys }}" - loop_control: - loop_var: "job_template" - label: "{{ job_template.job_template_name }}" - when: - - "tower_surveys | length > 0" diff --git a/roles/archive/ansible_tower_genie_surveys/vars/tower-secrets.yml b/roles/archive/ansible_tower_genie_surveys/vars/tower-secrets.yml deleted file mode 100644 index bb8ba226d..000000000 --- a/roles/archive/ansible_tower_genie_surveys/vars/tower-secrets.yml +++ /dev/null @@ -1,2 +0,0 @@ -# Placeholder file -# You should create an Ansible vault here when tower_secrets: true