From bd37045d28a0461985392509c2be88b01552f207 Mon Sep 17 00:00:00 2001 From: sean-m-sullivan Date: Mon, 2 Oct 2023 21:01:27 -0400 Subject: [PATCH] collection bugfix booleans default --- awx_collection/galaxy.yml | 1 + awx_collection/plugins/modules/host.py | 2 +- awx_collection/plugins/modules/instance.py | 4 ++-- awx_collection/plugins/modules/schedule.py | 2 +- .../integration/targets/host/tasks/main.yml | 20 +++++++++++++++++++ .../targets/schedule/tasks/main.yml | 9 +++++++++ 6 files changed, 34 insertions(+), 4 deletions(-) diff --git a/awx_collection/galaxy.yml b/awx_collection/galaxy.yml index b995bfe3e816..eb75c39c2a5f 100644 --- a/awx_collection/galaxy.yml +++ b/awx_collection/galaxy.yml @@ -36,3 +36,4 @@ build_ignore: - galaxy.yml.j2 - template_galaxy.yml - '*.tar.gz' + - tests diff --git a/awx_collection/plugins/modules/host.py b/awx_collection/plugins/modules/host.py index 9b8760b88fe1..e10d53b28324 100644 --- a/awx_collection/plugins/modules/host.py +++ b/awx_collection/plugins/modules/host.py @@ -81,7 +81,7 @@ def main(): new_name=dict(), description=dict(), inventory=dict(required=True), - enabled=dict(type='bool'), + enabled=dict(type='bool', default=True), variables=dict(type='dict'), state=dict(choices=['present', 'absent', 'exists'], default='present'), ) diff --git a/awx_collection/plugins/modules/instance.py b/awx_collection/plugins/modules/instance.py index 54866fb731ea..768646b33b73 100644 --- a/awx_collection/plugins/modules/instance.py +++ b/awx_collection/plugins/modules/instance.py @@ -99,8 +99,8 @@ def main(): argument_spec = dict( hostname=dict(required=True), capacity_adjustment=dict(type='float'), - enabled=dict(type='bool'), - managed_by_policy=dict(type='bool'), + enabled=dict(type='bool', default=True), + managed_by_policy=dict(type='bool', default=True), node_type=dict(type='str', choices=['execution', 'hop']), node_state=dict(type='str', choices=['deprovisioning', 'installed']), listener_port=dict(type='int'), diff --git a/awx_collection/plugins/modules/schedule.py b/awx_collection/plugins/modules/schedule.py index 4a6583629db4..ffa90fc3a510 100644 --- a/awx_collection/plugins/modules/schedule.py +++ b/awx_collection/plugins/modules/schedule.py @@ -219,7 +219,7 @@ def main(): verbosity=dict(type='int', choices=[0, 1, 2, 3, 4, 5]), unified_job_template=dict(), organization=dict(), - enabled=dict(type='bool'), + enabled=dict(type='bool', default=True), state=dict(choices=['present', 'absent', 'exists'], default='present'), ) diff --git a/awx_collection/tests/integration/targets/host/tasks/main.yml b/awx_collection/tests/integration/targets/host/tasks/main.yml index d7752ca6617a..fcb452838e17 100644 --- a/awx_collection/tests/integration/targets/host/tasks/main.yml +++ b/awx_collection/tests/integration/targets/host/tasks/main.yml @@ -20,6 +20,7 @@ host: name: "{{ host_name }}" inventory: "{{ result.id }}" + description: 1234 state: present variables: foo: bar @@ -29,6 +30,25 @@ that: - "result is changed" +- name: Create a Host check the result is not changed to make sure defaults passed + host: + name: "{{ host_name }}" + inventory: "{{ inv_name }}" + register: result + +- assert: + that: + - "result is not changed" + +- name: Use lookup to check that host was enabled + ansible.builtin.set_fact: + host_enabled_test: "lookup('awx.awx.controller_api', 'hosts/{{result.id}}/').enabled" + +- name: Newly created host should have API default value for enabled + assert: + that: + - host_enabled_test + - name: Create a Host with exists host: name: "{{ host_name }}" diff --git a/awx_collection/tests/integration/targets/schedule/tasks/main.yml b/awx_collection/tests/integration/targets/schedule/tasks/main.yml index df7e2d88e3c1..6f9eca1b33b6 100644 --- a/awx_collection/tests/integration/targets/schedule/tasks/main.yml +++ b/awx_collection/tests/integration/targets/schedule/tasks/main.yml @@ -76,6 +76,15 @@ that: - result is changed + - name: Use lookup to check that schedules was enabled + ansible.builtin.set_fact: + schedules_enabled_test: "lookup('awx.awx.controller_api', 'schedules/{{result.id}}/').enabled" + + - name: Newly created schedules should have API default value for enabled + assert: + that: + - schedules_enabled_test + - name: Build a real schedule with exists schedule: name: "{{ sched1 }}"