Skip to content

Commit

Permalink
Merge pull request #400 from automationiberia/add_export_settings
Browse files Browse the repository at this point in the history
add settings to filetree_create and custom_virtualenv for jt if tower
  • Loading branch information
silvinux authored Oct 26, 2022
2 parents d57b48f + d3a0601 commit 57ec9b5
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 1 deletion.
5 changes: 4 additions & 1 deletion roles/filetree_create/tasks/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
verify_ssl=controller_validate_certs).version is version('4.0.0', '>=') }}"

- name: Include tasks (block)
when: "['all', 'inventory', 'credentials', 'credential_types', 'notification_templates', 'users', 'teams', 'organizations', 'projects', 'execution_environments', 'job_templates', 'workflow_job_templates', 'workflow_job_template_nodes'] | intersect(input_tag) | length > 0"
when: "['all', 'settings', 'inventory', 'credentials', 'credential_types', 'notification_templates', 'users', 'teams', 'organizations', 'projects', 'execution_environments', 'job_templates', 'workflow_job_templates', 'workflow_job_template_nodes'] | intersect(input_tag) | length > 0"
block:
- name: "Export Inventories and related Groups and Hosts"
ansible.builtin.include_tasks: "inventory.yml"
Expand Down Expand Up @@ -41,4 +41,7 @@
- name: "Export Workflow Job Templates"
ansible.builtin.include_tasks: "workflow_job_templates.yml"
when: "'workflow_job_templates' in input_tag or 'all' in input_tag"
- name: "Export Settings"
ansible.builtin.include_tasks: "settings.yml"
when: "'settings' in input_tag or 'all' in input_tag"
...
20 changes: 20 additions & 0 deletions roles/filetree_create/tasks/settings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
- name: "Get current Settings from the API"
ansible.builtin.set_fact:
changed_settings: "{{ query(controller_api_plugin, 'api/v2/settings/changed/',
host=controller_hostname, oauth_token=controller_oauthtoken, verify_ssl=controller_validate_certs,
return_all=true, max_objects=query_controller_api_max_objects)
}}"

- name: "Create the output directory for credential types: {{ output_path }}"
ansible.builtin.file:
path: "{{ output_path }}"
state: directory
mode: '0755'

- name: "Add current settings to the settings.yaml output file in {{ output_path }}"
ansible.builtin.template:
src: "templates/current_settings.j2"
dest: "{{ output_path }}/current_settings.yaml"
mode: '0644'
...
3 changes: 3 additions & 0 deletions roles/filetree_create/templates/current_job_templates.j2
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,7 @@ controller_templates:
{% if is_aap %}
execution_environment: "{{ current_job_templates_asset_value.summary_fields.execution_environment.name | default(omit) }}"
{% endif %}
{% if not is_aap %}
custom_virtualenv: "{{ current_job_templates_asset_value.custom_virtualenv | default(omit) }}"
{% endif %}
...
4 changes: 4 additions & 0 deletions roles/filetree_create/templates/current_settings.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
controller_settings:
- settings: "{{ changed_settings[0] | replace('\'AUTH_LDAP_GROUP_TYPE_PARAMS\': {}', '\'AUTH_LDAP_GROUP_TYPE_PARAMS\': {\'name_attr\': \'cn\', \'member_attr\': \'member\'}') }}"
...
1 change: 1 addition & 0 deletions roles/filetree_create/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# vars file for filetree_create
valid_tags:
- all
- settings
- credentials
- credential_types
- execution_environments
Expand Down

0 comments on commit 57ec9b5

Please sign in to comment.