-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add ansible host to insights configuration
Adds the ansible host name option for insights-client into the rhc role. This adds support for setting an ansible host name in HBI during insights-client registration, updating the current ansible host name in HBI if the system is already registered, and resetting the ansible host name if an absent value is provided. Signed-off-by: Jason Jerome <[email protected]>
- Loading branch information
Showing
5 changed files
with
194 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
# SPDX-License-Identifier: MIT | ||
--- | ||
- name: Insights ansible host test | ||
hosts: all | ||
gather_facts: false | ||
become: true | ||
|
||
tasks: | ||
- name: Setup Insights | ||
import_tasks: tasks/setup_insights.yml | ||
|
||
- name: Test ansible_host | ||
block: | ||
- name: Add ansible_host and register insights | ||
include_role: | ||
name: linux-system-roles.rhc | ||
public: true | ||
vars: | ||
rhc_auth: | ||
login: | ||
username: "{{ lsr_rhc_test_data.reg_username }}" | ||
password: "{{ lsr_rhc_test_data.reg_password }}" | ||
rhc_insights: | ||
ansible_host: host | ||
remediation: absent | ||
state: present | ||
rhc_organization: "{{ lsr_rhc_test_data.reg_organization }}" | ||
rhc_server: | ||
hostname: "{{ lsr_rhc_test_data.candlepin_host }}" | ||
port: "{{ lsr_rhc_test_data.candlepin_port }}" | ||
prefix: "{{ lsr_rhc_test_data.candlepin_prefix }}" | ||
insecure: "{{ lsr_rhc_test_data.candlepin_insecure }}" | ||
rhc_baseurl: "{{ lsr_rhc_test_data.baseurl | d(omit) }}" | ||
|
||
- name: Check ansible_host is set to 'host' in config file | ||
command: | ||
grep -ixq "^ansible_host=host" {{ __rhc_insights_conf }} | ||
changed_when: true | ||
|
||
- name: Test ansible_host changed value after registration | ||
block: | ||
- name: Change ansible host to 'new-host' | ||
include_role: | ||
name: linux-system-roles.rhc | ||
vars: | ||
rhc_insights: | ||
ansible_host: new-host | ||
remediation: absent | ||
- name: Check ansible_host is set to 'new-host' in config file | ||
command: | ||
grep -ixq "^ansible_host=new-host" {{ __rhc_insights_conf }} | ||
changed_when: false | ||
- name: Change ansible host to a null value (noop) | ||
include_role: | ||
name: linux-system-roles.rhc | ||
vars: | ||
rhc_insights: | ||
ansible_host: null | ||
remediation: absent | ||
- name: Check ansible_host has not changed in config file | ||
command: | ||
grep -ixq "^ansible_host=new-host" {{ __rhc_insights_conf }} | ||
changed_when: false | ||
|
||
- name: Test ansible_host set to an absent value | ||
block: | ||
- name: Set ansible host to an absent value | ||
include_role: | ||
name: linux-system-roles.rhc | ||
vars: | ||
rhc_insights: | ||
ansible_host: {state: absent} | ||
remediation: absent | ||
- name: Check ansible_host is not present in config file | ||
lineinfile: | ||
path: "{{ __rhc_insights_conf }}" | ||
regexp: "^ansible_host=" | ||
state: absent | ||
check_mode: true | ||
register: __test_ansible_host_absent | ||
failed_when: __test_ansible_host_absent.found | ||
|
||
- name: Test ansible_host is removed during insights unregistration | ||
block: | ||
- name: Set ansible_host in config file | ||
include_role: | ||
name: linux-system-roles.rhc | ||
vars: | ||
rhc_insights: | ||
ansible_host: unreg-test | ||
remediation: absent | ||
- name: Check ansible_host is set in config file | ||
command: | ||
grep -ixq "^ansible_host=unreg-test" {{ __rhc_insights_conf }} | ||
changed_when: false | ||
- name: Unregister insights to remove ansible_host in config file | ||
include_role: | ||
name: linux-system-roles.rhc | ||
vars: | ||
rhc_insights: | ||
state: absent | ||
- name: Check ansible_host is not present in config file | ||
lineinfile: | ||
path: "{{ __rhc_insights_conf }}" | ||
regexp: "^ansible_host=" | ||
state: absent | ||
check_mode: true | ||
register: __test_ansible_host_removed | ||
failed_when: __test_ansible_host_removed.found | ||
|
||
always: | ||
- name: Unregister | ||
include_role: | ||
name: linux-system-roles.rhc | ||
vars: | ||
rhc_state: absent |