Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename current objects to controller_ naming convention #29

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/disabled_workflows/ci_standalone_versioned.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ jobs:
run: ansible-galaxy collection install -r .github/collections/requirements.yml

- name: "Perform playbook tests"
run: ansible-playbook tests/configure_controller.yml -e controller_hostname=localhost:8043 -v -e awx_version=${{ inputs.awx_version }}
run: ansible-playbook tests/configure_controller.yml -e aap_hostname=localhost:8043 -v -e awx_version=${{ inputs.awx_version }}

- name: "Perform export model playbook tests"
run: ansible-playbook tests/configure_controller_export_model.yml -e controller_hostname=localhost:8043 -v -e awx_version=${{ inputs.awx_version }}
run: ansible-playbook tests/configure_controller_export_model.yml -e aap_hostname=localhost:8043 -v -e awx_version=${{ inputs.awx_version }}
...
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ Otherwise it will look for the modules only in your base installation. If there
```

Define following vars here, or in `controller_configs/controller_auth.yml`
`controller_hostname: ansible-controller-web-svc-test-project.example.com`
`aap_hostname: ansible-controller-web-svc-test-project.example.com`

You can also specify authentication by a combination of either:

- `controller_hostname`, `controller_username`, `controller_password`
- `controller_hostname`, `controller_oauthtoken`
- `aap_hostname`, `aap_username`, `aap_password`
- `aap_hostname`, `aap_oauthtoken`

The OAuth2 token is the preferred method. You can obtain the token through the preferred `controller_token` module, or through the
AWX CLI [login](https://docs.ansible.com/automation-controller/latest/html/controllerapi/authentication.html)
Expand Down Expand Up @@ -129,9 +129,9 @@ Controller token module would be invoked with this code:
description: 'Creating token to test controller jobs'
scope: "write"
state: present
controller_host: "{{ controller_hostname }}"
controller_username: "{{ controller_username }}"
controller_password: "{{ controller_password }}"
controller_host: "{{ aap_hostname }}"
aap_username: "{{ aap_username }}"
aap_password: "{{ aap_password }}"

```

Expand Down
16 changes: 8 additions & 8 deletions docs/CONVERSION_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ The Following Variables need to be changed:
|:---:|:---:|
|`tower_ad_hoc_commands`|`controller_ad_hoc_commands`|
|`tower_ad_hoc_commands_cancel`|`controller_ad_hoc_commands_cancel`|
|`tower_applications`|`controller_applications`|
|`tower_applications`|`aap_applications`|
|`tower_credential_input_sources`|`controller_credential_input_sources`|
|`tower_credential_types`|`controller_credential_types`|
|`tower_credentials`|`controller_credentials`|
Expand All @@ -46,24 +46,24 @@ The Following Variables need to be changed:
|`tower_labels`|`controller_labels`|
|`tower_license`|`controller_license`|
|`tower_notifications`|`controller_notifications`|
|`tower_organizations`|`controller_organizations`|
|`tower_organizations`|`aap_organizations`|
|`tower_projects`|`controller_projects`|
|`tower_rbac`|`controller_roles`|
|`tower_schedules`|`controller_schedules`|
|`tower_settings`|`controller_settings`|
|`tower_teams`|`controller_teams`|
|`tower_user_accounts`|`controller_user_accounts`|
|`tower_teams`|`aap_teams`|
|`tower_user_accounts`|`aap_user_accounts`|
|`tower_workflows`|`controller_workflows`|
|`tower_workflow_launch_jobs`|`controller_workflow_launch_jobs`|

### Authentication Credentials

|Tower Variable Name|Controller Variable Name|
|:---:|:---:|
|`tower_username`|`controller_username`|
|`tower_password`|`controller_password`|
|`tower_oauthtoken`|`controller_oauthtoken`|
|`tower_hostname`|`controller_hostname`|
|`tower_username`|`aap_username`|
|`tower_password`|`aap_password`|
|`tower_oauthtoken`|`aap_oauthtoken`|
|`tower_hostname`|`aap_hostname`|
|`tower_config_file`|`controller_config_file`|
|`tower_validate_certs`|`controller_validate_certs`|

Expand Down
24 changes: 12 additions & 12 deletions playbooks/flatten_filetree_create_output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
gather_facts: false
vars:
filetree_controller_settings: &filetree_create_output_dir "{{ filetree_create_output_dir }}"
filetree_controller_organizations: *filetree_create_output_dir
filetree_aap_organizations: *filetree_create_output_dir
filetree_controller_labels: *filetree_create_output_dir
filetree_controller_user_accounts: *filetree_create_output_dir
filetree_controller_teams: *filetree_create_output_dir
filetree_aap_user_accounts: *filetree_create_output_dir
filetree_aap_teams: *filetree_create_output_dir
filetree_controller_credential_types: *filetree_create_output_dir
filetree_controller_credentials: *filetree_create_output_dir
filetree_controller_credential_input_sources: *filetree_create_output_dir
filetree_controller_notifications: *filetree_create_output_dir
filetree_controller_projects: *filetree_create_output_dir
filetree_controller_execution_environments: *filetree_create_output_dir
filetree_controller_applications: *filetree_create_output_dir
filetree_aap_applications: *filetree_create_output_dir
filetree_controller_inventories: *filetree_create_output_dir
filetree_controller_inventory_sources: *filetree_create_output_dir
filetree_controller_instance_groups: *filetree_create_output_dir
Expand Down Expand Up @@ -47,14 +47,14 @@
loop:
- name: controller_settings
value: "{{ controller_settings }}"
- name: controller_organizations
value: "{{ controller_organizations }}"
- name: aap_organizations
value: "{{ aap_organizations }}"
- name: controller_labels
value: "{{ controller_labels }}"
- name: controller_user_accounts
value: "{{ controller_user_accounts }}"
- name: controller_teams
value: "{{ controller_teams }}"
- name: aap_user_accounts
value: "{{ aap_user_accounts }}"
- name: aap_teams
value: "{{ aap_teams }}"
- name: controller_credential_types
value: "{{ controller_credential_types }}"
- name: controller_credentials
Expand All @@ -67,8 +67,8 @@
value: "{{ controller_projects }}"
- name: controller_execution_environments
value: "{{ controller_execution_environments }}"
- name: controller_applications
value: "{{ controller_applications }}"
- name: aap_applications
value: "{{ aap_applications }}"
- name: controller_inventories
value: "{{ controller_inventories }}"
- name: controller_inventory_sources
Expand Down
24 changes: 12 additions & 12 deletions playbooks/get_stats.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
gather_facts: true
vars:
# Using the Tower env names for backwards compatibility
controller_hostname: "{{ lookup('ansible.builtin.env', 'TOWER_HOST') }}"
controller_username: "{{ lookup('ansible.builtin.env', 'TOWER_USERNAME') }}"
controller_password: "{{ lookup('ansible.builtin.env', 'TOWER_PASSWORD') }}"
aap_hostname: "{{ lookup('ansible.builtin.env', 'TOWER_HOST') }}"
aap_username: "{{ lookup('ansible.builtin.env', 'TOWER_USERNAME') }}"
aap_password: "{{ lookup('ansible.builtin.env', 'TOWER_PASSWORD') }}"
controller_validate_certs: "{{ lookup('ansible.builtin.env', 'TOWER_VERIFY_SSL') | default(false) }}"

tasks:
- name: Get number of JT
ansible.builtin.uri:
url: "https://{{ controller_hostname }}/api/v2/metrics/?format=json"
url: "https://{{ aap_hostname }}/api/controller/v2/metrics/?format=json"
method: GET
force_basic_auth: true
user: "{{ controller_username }}"
password: "{{ controller_password }}"
user: "{{ aap_username }}"
password: "{{ aap_password }}"
return_content: true
headers:
Content-Type: application/json
Expand All @@ -39,11 +39,11 @@

- name: Get users info
ansible.builtin.uri:
url: "https://{{ controller_hostname }}/api/v2/users/?format=json"
url: "https://{{ aap_hostname }}/api/controller/v2/users/?format=json"
method: GET
force_basic_auth: true
user: "{{ controller_username }}"
password: "{{ controller_password }}"
user: "{{ aap_username }}"
password: "{{ aap_password }}"
return_content: true
headers:
Content-Type: application/json
Expand Down Expand Up @@ -82,11 +82,11 @@

- name: Get subscription info
ansible.builtin.uri:
url: "https://{{ controller_hostname }}/api/v2/settings/all/?format=json"
url: "https://{{ aap_hostname }}/api/controller/v2/settings/all/?format=json"
method: GET
force_basic_auth: true
user: "{{ controller_username }}"
password: "{{ controller_password }}"
user: "{{ aap_username }}"
password: "{{ aap_password }}"
return_content: true
headers:
Content-Type: application/json
Expand Down
10 changes: 5 additions & 5 deletions plugins/lookup/controller_object_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@
- name: Get the organization ID
set_fact:
controller_organization_id: "{{ lookup('awx.awx.controller_api', 'organizations', query_params={ 'name': 'Default' },
host=controller_hostname, username=controller_username, password=controller_password, verify_ssl=false) }}"
host=aap_hostname, username=aap_username, password=aap_password, verify_ssl=false) }}"

- name: "Get the API list of all Projects in the Default Organization"
set_fact:
controller_api_results: "{{ lookup('awx.awx.controller_api', 'projects', query_params={ 'organization':
controller_organization_id.id } ,host=controller_hostname, username=controller_username,
password=controller_password, verify_ssl=false) }}"
controller_organization_id.id } ,host=aap_hostname, username=aap_username,
password=aap_password, verify_ssl=false) }}"

- name: "Get the API in a list form. Useful for making sure the results of one item is set to a list."
set_fact:
controller_api_results: "{{ query('awx.awx.controller_api', 'inventories', query_params={ 'organization':
controller_organization_id.id } ,host=controller_hostname, username=controller_username,
password=controller_password, verify_ssl=false) }}"
controller_organization_id.id } ,host=aap_hostname, username=aap_username,
password=aap_password, verify_ssl=false) }}"

- name: "Find the difference of Project between what is on the Controller versus curated list."
set_fact:
Expand Down
10 changes: 4 additions & 6 deletions plugins/modules/controller_export_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,12 @@
aliases: [ tower_host ]
controller_username:
description:
- Username for your controller instance.
- If value not set, will try environment variable C(CONTROLLER_USERNAME) and then config files
- Username to connect to your Automation Platform Controller instance.
type: str
aliases: [ tower_username ]
controller_password:
description:
- Password for your controller instance.
- If value not set, will try environment variable C(CONTROLLER_PASSWORD) and then config files
- Password to connect to your Automation Platform Controller instance.
type: str
aliases: [ tower_password ]
controller_oauthtoken:
Expand Down Expand Up @@ -194,8 +192,8 @@
credential: gitlab-personal-access-token for satqe_auto_droid
wait: false
controller_host: https://controller
controller_username: admin
controller_password: secret123
aap_username: admin
aap_password: secret123
validate_certs: false
register: export_results
...
Expand Down
8 changes: 4 additions & 4 deletions roles/aap_rules_validation/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ __object_var_names:
projects: controller_projects
job_templates: controller_templates
inventories: controller_inventories
applications: controller_applications
applications: aap_applications
hosts: controller_hosts
credential_input_sources: controller_credential_input_sources
credentials: controller_credentials
Expand All @@ -47,11 +47,11 @@ __object_var_names:
inventory_sources: controller_inventory_sources
labels: controller_labels
notification_templates: controller_notifications
organizations: controller_organizations
organizations: aap_organizations
roles: controller_roles
settings: controller_settings
teams: controller_teams
users: controller_user_accounts
teams: aap_teams
users: aap_user_accounts
workflow_job_templates: controller_workflows
schedules: controller_schedules

Expand Down
6 changes: 3 additions & 3 deletions roles/aap_rules_validation/tasks/check_users.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
msg: "Rule {{ rule_id }} | users | {{ __user_org }} | {{ __username }} | The user's password is not encrypted"
__username: "{{ __unencrypted_user['username'] | default(__unencrypted_user['user']) }}"
__user_org: "{{ __unencrypted_user['organization'] | default('__undefined_org__') }}"
loop: "{{ controller_user_accounts | selectattr('password', 'defined') | rejectattr('password', 'vault_encrypted') }}"
loop: "{{ aap_user_accounts | selectattr('password', 'defined') | rejectattr('password', 'vault_encrypted') }}"
when: rule['encrypt_user_passwords'] is defined
and rule['encrypt_user_passwords'] | bool
and __unencrypted_user['username'] | default(__unencrypted_user['user']) not in (rule['exceptions']['users'] | default([]))
Expand All @@ -46,7 +46,7 @@
msg: "Rule {{ rule_id }} | users | {{ __user_org }} | {{ __username }} | Superusers are not allowed"
__username: "{{ __superusers['username'] | default(__superusers['user']) }}"
__user_org: "{{ __superusers['organization'] | default('__undefined_org__') }}"
loop: "{{ controller_user_accounts | selectattr('is_superuser', 'defined') | rejectattr('is_superuser', 'false') }}"
loop: "{{ aap_user_accounts | selectattr('is_superuser', 'defined') | rejectattr('is_superuser', 'false') }}"
when: rule['allow_superusers'] is defined
and not rule['allow_superusers'] | bool
and __superusers['username'] | default(__superusers['user']) not in (rule['exceptions']['users'] | default([]))
Expand Down Expand Up @@ -76,7 +76,7 @@
when: rule['allow_system_auditors'] is defined
and not rule['allow_system_auditors'] | bool
and __system_auditors['username'] | default(__system_auditors['user']) not in (rule['exceptions']['users'] | default([]))
loop: "{{ controller_user_accounts | selectattr('is_system_auditor', 'defined') | rejectattr('is_system_auditor', 'false') }}"
loop: "{{ aap_user_accounts | selectattr('is_system_auditor', 'defined') | rejectattr('is_system_auditor', 'false') }}"
loop_control:
loop_var: __system_auditors
...
10 changes: 5 additions & 5 deletions roles/aap_rules_validation/tasks/rule_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@
- name: Organizations specific checks - {{ object_type }}
ansible.builtin.include_tasks:
file: tasks/check_organizations.yml
when: controller_organizations is defined
and controller_organizations | length > 0
when: aap_organizations is defined
and aap_organizations | length > 0
and 'organizations' in rule['objects']
and (org['name'] in rule['organizations'] if rule['organizations'] is defined else true)
loop: "{{ controller_organizations }}"
loop: "{{ aap_organizations }}"
loop_control:
loop_var: org

Expand Down Expand Up @@ -78,8 +78,8 @@
- name: User specific checks
ansible.builtin.include_tasks:
file: tasks/check_users.yml
when: controller_user_accounts is defined
and controller_user_accounts | length > 0
when: aap_user_accounts is defined
and aap_user_accounts | length > 0
and 'users' in rule['objects']
and
(
Expand Down
Loading