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

added populate aap vars #255

Closed
Closed
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
21 changes: 21 additions & 0 deletions roles/populate_aap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,27 @@ None
|`populate_aap_credentials`|None|no|list|Use to populate AAP with credentials. More information can be found in [Configuration Collection credentials role README](https://github.com/redhat-cop/controller_configuration/tree/devel/roles/credentials)|<pre>populate_aap_credentials:<br> - name: osbuild_credential<br> organization: Osbuild_test<br> credentail_type: Machine<br> inputs:<br> username: user<br> ssh_key_data: "{{ lookup('file', '~/.ssh/id_rsa_aap', errors='warn') }}" </pre>|
|`populate_aap_job_templates`|None|no|list|Use to populate AAP with job templates. More information can be found in [Configuration Collection job templates role README](https://github.com/redhat-cop/controller_configuration/tree/devel/roles/job_templates)|<pre>populate_aap_job_templates:<br> - name: osbuild_setup_server<br> job_type: run<br> inventory: osbuild_inventory<br> project: osbuild_project<br> playbook: playbooks/<br> osbuild_setup_server.yml<br> credentials:<br> - osbuild_credential</pre>|

### populate_aap_default_host_user

Type: string
Required: false

Default host user for the remote system.

### populate_aap_default_host_ip

Type: string
Required: false

Default ip for the remote system.

### populate_aap_ssh_key_path

Type: string
Required: false

Path to the private ssh key that will be used for communication remote systems.

## Variables Exported by the Role

None.
Expand Down
11 changes: 6 additions & 5 deletions roles/populate_aap/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ populate_aap_execution_environment_name: osbuild_ee
populate_aap_inventory_name: osbuild_inventory
populate_aap_project_name: osbuild_project
populate_aap_credential_name: osbuild_credential
populate_aap_default_host_user: user
populate_aap_default_host_ip: 0.0.0.0
populate_aap_organizations:
- name: "{{ populate_aap_organization_name }}"
populate_aap_execution_environments:
Expand All @@ -23,8 +25,8 @@ populate_aap_hosts:
- name: osbuild_remote_system
inventory: "{{ populate_aap_inventory_name }}"
variables:
ansible_host: 0.0.0.0
ansible_user: user
ansible_host: "{{ populate_aap_default_host_ip }}"
ansible_user: "{{ populate_aap_default_host_user }}"
populate_aap_projects:
- name: "{{ populate_aap_project_name }}"
organization: "{{ populate_aap_organization_name }}"
Expand All @@ -36,8 +38,8 @@ populate_aap_credentials:
organization: "{{ populate_aap_organization_name }}"
credential_type: Machine
inputs:
username: user
ssh_key_data: "{{ lookup('file', '/home/user/.ssh/id_rsa') }}"
username: "{{ populate_aap_default_host_user }}"
ssh_key_data: "{{ lookup('file', populate_aap_ssh_key_path) if populate_aap_ssh_key_path is defined else '' }}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be just the var {{ populate_aap_ssh_key_path }} and the role should contain all of the non variable information and then this would close the other issue #213
This is a best practice that the defaults should be vars not logic.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ssh_key_data: "{{ lookup('file', populate_aap_ssh_key_path) if populate_aap_ssh_key_path is defined else '' }}"
ssh_key_data: "{{ populate_aap_ssh_key_path }}"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in addition to above you will need to change the role main task to have the lookup

populate_aap_job_templates:
- name: osbuild_setup_server
job_type: run
Expand All @@ -57,7 +59,6 @@ populate_aap_job_templates:
ask_variables_on_launch: true
extra_vars:
_docs: 'REPLACE WITH VARS FROM DOCS: https://github.com/redhat-cop/infra.osbuild/blob/main/roles/builder/APP_EXTRA_VARS.md' # yamllint disable-line rule:line-length

credentials:
- "{{ populate_aap_credential_name }}"

Expand Down
2 changes: 1 addition & 1 deletion roles/populate_aap/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@
name: redhat_cop.controller_configuration.organizations
when: controller_organizations is defined

- name: Configure execution enviornment for AAP
- name: Configure execution environment for AAP
ansible.builtin.include_role:
name: redhat_cop.controller_configuration.execution_environments
when: controller_execution_environments is defined
Expand Down