Skip to content

Commit

Permalink
collection bugfix booleans default
Browse files Browse the repository at this point in the history
  • Loading branch information
sean-m-sullivan committed Oct 3, 2023
1 parent 0558270 commit bd37045
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 4 deletions.
1 change: 1 addition & 0 deletions awx_collection/galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ build_ignore:
- galaxy.yml.j2
- template_galaxy.yml
- '*.tar.gz'
- tests
2 changes: 1 addition & 1 deletion awx_collection/plugins/modules/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
)
Expand Down
4 changes: 2 additions & 2 deletions awx_collection/plugins/modules/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
2 changes: 1 addition & 1 deletion awx_collection/plugins/modules/schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
)

Expand Down
20 changes: 20 additions & 0 deletions awx_collection/tests/integration/targets/host/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
host:
name: "{{ host_name }}"
inventory: "{{ result.id }}"
description: 1234
state: present
variables:
foo: bar
Expand All @@ -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 }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand Down

0 comments on commit bd37045

Please sign in to comment.