Skip to content

Commit

Permalink
test: updated tests for ansible hosts
Browse files Browse the repository at this point in the history
Signed-off-by: Jason Jerome <jajerome@redhat.com>
  • Loading branch information
DuckBoss committed Jan 5, 2024
1 parent 3395fd0 commit aaa65a0
Showing 1 changed file with 71 additions and 26 deletions.
97 changes: 71 additions & 26 deletions tests/tests_insights_ansible_host.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
username: "{{ lsr_rhc_test_data.reg_username }}"
password: "{{ lsr_rhc_test_data.reg_password }}"
rhc_insights:
ansible_host: test-host
ansible_host: host
remediation: absent
state: present
rhc_organization: "{{ lsr_rhc_test_data.reg_organization }}"
Expand All @@ -32,36 +32,81 @@
insecure: "{{ lsr_rhc_test_data.candlepin_insecure }}"
rhc_baseurl: "{{ lsr_rhc_test_data.baseurl | d(omit) }}"

- name: Check ansible host is set to 'test-host' in config file
- name: Check ansible_host is set to 'host' in config file
command:
grep -ixq "^ansible_host=test-host" {{ __rhc_insights_conf }}
grep -ixq "^ansible_host=host" {{ __rhc_insights_conf }}
changed_when: true

- name: Change ansible host to 'new-test-host'
include_role:
name: linux-system-roles.rhc
vars:
rhc_insights:
ansible_host: new-test-host
remediation: absent
- 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: true
- 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: true

- name: Check ansible_host is set to 'new-test-host' in config file
command:
grep -ixq "^ansible_host=new-test-host" {{ __rhc_insights_conf }}
changed_when: true
- 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: 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-test-host" {{ __rhc_insights_conf }}
changed_when: true
- 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: true
- 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
Expand Down

0 comments on commit aaa65a0

Please sign in to comment.