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

collection bugfix booleans default value to match api #14528

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
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
3 changes: 2 additions & 1 deletion awx_collection/plugins/modules/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
description:
- If the host should be enabled.
type: bool
default: true
Copy link
Member

Choose a reason for hiding this comment

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

This is going to set the enabled flag to true for any existing host where the option isn't specified.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you are right..........................................................................................................................................................................................................................................................................................................................................................................................................................................................

variables:
description:
- Variables to use for the host.
Expand Down Expand Up @@ -81,7 +82,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
6 changes: 4 additions & 2 deletions awx_collection/plugins/modules/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@
- If true, the instance will be enabled and used.
required: False
type: bool
default: true
managed_by_policy:
description:
- Managed by policy
required: False
type: bool
default: true
node_type:
description:
- Role that this node plays in the mesh.
Expand Down Expand Up @@ -99,8 +101,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
3 changes: 2 additions & 1 deletion awx_collection/plugins/modules/schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
- Enables processing of this schedule.
required: False
type: bool
default: true
state:
description:
- Desired state of the resource.
Expand Down Expand Up @@ -219,7 +220,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
Loading