Skip to content

Commit

Permalink
Revised enforced defaults (#590)
Browse files Browse the repository at this point in the history
* update org export

* update org export

* rebase

* revised enforced defaults
  • Loading branch information
sean-m-sullivan authored Apr 28, 2023
1 parent 5344f34 commit 71a5247
Show file tree
Hide file tree
Showing 26 changed files with 197 additions and 279 deletions.
1 change: 0 additions & 1 deletion changelogs/fragments/enforce_defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ minor_changes:
- Credentials role credential type set to mandatory. This would fail in the past if it was not set, this just codifies it.
- Instances role - changed default of node_type and node_state to omit, as generally these cannot be changed on existing instances unless deploying new instances.
- Inventory role - added input_inventories option for constructed inventories.
- Schedule role - rrule set to mandatory. This would fail in the past if it was not set, this just codifies it.
...
74 changes: 0 additions & 74 deletions plugins/lookup/enforce_defaults.py

This file was deleted.

4 changes: 2 additions & 2 deletions roles/applications/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
name: "{{ __application_item.name | mandatory }}"
new_name: "{{ __application_item.new_name | default(omit, true) }}"
organization: "{{ __application_item.organization | mandatory }}"
description: "{{ __application_item.description | default(lookup('infra.controller_configuration.enforce_defaults', enforce_default=controller_configuration_applications_enforce_defaults , default_value='', omit_value=omit), true) }}"
description: "{{ __application_item.description | default(( '' if controller_configuration_applications_enforce_defaults else omit), true) }}"
authorization_grant_type: "{{ __application_item.authorization_grant_type | default('password') }}"
client_type: "{{ __application_item.client_type | default('public') }}"
redirect_uris: "{{ __application_item.redirect_uris | default([]) }}"
skip_authorization: "{{ __application_item.skip_authorization | default(lookup('infra.controller_configuration.enforce_defaults', enforce_default=controller_configuration_applications_enforce_defaults , default_value=false, omit_value=omit), true) }}"
skip_authorization: "{{ __application_item.skip_authorization | default(( false if controller_configuration_applications_enforce_defaults else omit), true) }}"
state: "{{ __application_item.state | default(controller_state | default('present')) }}"

# Role specific options
Expand Down
4 changes: 2 additions & 2 deletions roles/credential_input_sources/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
target_credential: "{{ __cred_input_src_item.target_credential | mandatory }}"
input_field_name: "{{ __cred_input_src_item.input_field_name | mandatory }}"
source_credential: "{{ __cred_input_src_item.source_credential | default(omit, true) }}"
description: "{{ __cred_input_src_item.description | default(lookup('infra.controller_configuration.enforce_defaults', enforce_default=controller_configuration_credential_input_sources_enforce_defaults , default_value='', omit_value=omit), true) }}"
metadata: "{{ __cred_input_src_item.metadata | default(lookup('infra.controller_configuration.enforce_defaults', enforce_default=controller_configuration_credential_input_sources_enforce_defaults , default_value={}, omit_value=omit), true) }}"
description: "{{ __cred_input_src_item.description | default(( '' if controller_configuration_credential_input_sources_enforce_defaults else omit), true) }}"
metadata: "{{ __cred_input_src_item.metadata | default(( {} if controller_configuration_credential_input_sources_enforce_defaults else omit), true) }}"
state: "{{ __cred_input_src_item.state | default(controller_state | default('present')) }}"

# Role specific options
Expand Down
6 changes: 3 additions & 3 deletions roles/credential_types/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
credential_type:
name: "{{ __controller_credential_type_item.name | mandatory }}"
new_name: "{{ __controller_credential_type_item.new_name | default(omit, true) }}"
description: "{{ __controller_credential_type_item.description | default(lookup('infra.controller_configuration.enforce_defaults', enforce_default=controller_configuration_credential_types_enforce_defaults , default_value='', omit_value=omit), true) }}"
injectors: "{{ __controller_credential_type_item.injectors | default(lookup('infra.controller_configuration.enforce_defaults', enforce_default=controller_configuration_credential_types_enforce_defaults , default_value={}, omit_value=omit), true) | regex_replace('[ ]{2,}', '') }}"
inputs: "{{ __controller_credential_type_item.inputs | default(lookup('infra.controller_configuration.enforce_defaults', enforce_default=controller_configuration_credential_types_enforce_defaults , default_value={}, omit_value=omit), true) }}"
description: "{{ __controller_credential_type_item.description | default(( '' if controller_configuration_credential_types_enforce_defaults else omit), true) }}"
injectors: "{{ __controller_credential_type_item.injectors | default(( {} if controller_configuration_credential_types_enforce_defaults else omit), true) | regex_replace('[ ]{2,}', '') }}"
inputs: "{{ __controller_credential_type_item.inputs | default(( {} if controller_configuration_credential_types_enforce_defaults else omit), true) }}"
kind: "{{ __controller_credential_type_item.kind | default('cloud') }}"
state: "{{ __controller_credential_type_item.state | default(controller_state | default('present')) }}"

Expand Down
12 changes: 6 additions & 6 deletions roles/credentials/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
name: "{{ __controller_credentials_item.name | mandatory }}"
new_name: "{{ __controller_credentials_item.new_name | default(omit, true) }}"
copy_from: "{{ __controller_credentials_item.copy_from | default(omit, true) }}"
description: "{{ __controller_credentials_item.description | default(lookup('infra.controller_configuration.enforce_defaults', enforce_default=controller_configuration_credentials_enforce_defaults , default_value='', omit_value=omit), true) }}"
organization: "{{ __controller_credentials_item.organization.name | default(__controller_credentials_item.organization | default(lookup('infra.controller_configuration.enforce_defaults', enforce_default=controller_configuration_credentials_enforce_defaults , default_value='', omit_value=omit), true)) }}"
description: "{{ __controller_credentials_item.description | default(( '' if controller_configuration_credentials_enforce_defaults else omit), true) }}"
organization: "{{ __controller_credentials_item.organization.name | default(__controller_credentials_item.organization | default(( '' if controller_configuration_credentials_enforce_defaults else omit), true)) }}"
credential_type: "{{ __controller_credentials_item.credential_type.name | default(__controller_credentials_item.credential_type | mandatory ) }}"
inputs: "{{ __controller_credentials_item.inputs | default(lookup('infra.controller_configuration.enforce_defaults', enforce_default=controller_configuration_credentials_enforce_defaults , default_value={}, omit_value=omit), true) }}"
user: "{{ __controller_credentials_item.user.username | default(__controller_credentials_item.user | default(lookup('infra.controller_configuration.enforce_defaults', enforce_default=controller_configuration_credentials_enforce_defaults , default_value='', omit_value=omit), true)) }}"
team: "{{ __controller_credentials_item.team.name | default(__controller_credentials_item.team | default(lookup('infra.controller_configuration.enforce_defaults', enforce_default=controller_configuration_credentials_enforce_defaults , default_value='', omit_value=omit), true)) }}"
update_secrets: "{{ __controller_credentials_item.update_secrets | default(lookup('infra.controller_configuration.enforce_defaults', enforce_default=controller_configuration_credentials_enforce_defaults , default_value=true, omit_value=omit), true) }}"
inputs: "{{ __controller_credentials_item.inputs | default(( {} if controller_configuration_credentials_enforce_defaults else omit), true) }}"
user: "{{ __controller_credentials_item.user.username | default(__controller_credentials_item.user | default(( '' if controller_configuration_credentials_enforce_defaults else omit), true)) }}"
team: "{{ __controller_credentials_item.team.name | default(__controller_credentials_item.team | default(( '' if controller_configuration_credentials_enforce_defaults else omit), true)) }}"
update_secrets: "{{ __controller_credentials_item.update_secrets | default(( true if controller_configuration_credentials_enforce_defaults else omit), true) }}"
state: "{{ __controller_credentials_item.state | default(controller_state | default('present')) }}"

# Role specific options
Expand Down
8 changes: 4 additions & 4 deletions roles/execution_environments/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
execution_environment:
name: "{{ __execution_environments_item.name | mandatory }}"
new_name: "{{ __execution_environments_item.new_name | default(omit, true) }}"
description: "{{ __execution_environments_item.description | default(lookup('infra.controller_configuration.enforce_defaults', enforce_default=controller_configuration_execution_environments_enforce_defaults , default_value='', omit_value=omit), true) }}"
description: "{{ __execution_environments_item.description | default(( '' if controller_configuration_execution_environments_enforce_defaults else omit), true) }}"
image: "{{ __execution_environments_item.image | mandatory }}"
organization: "{{ __execution_environments_item.organization.name | default(__execution_environments_item.organization | default(lookup('infra.controller_configuration.enforce_defaults', enforce_default=controller_configuration_execution_environments_enforce_defaults , default_value='', omit_value=omit), true)) }}"
credential: "{{ __execution_environments_item.credential | default(lookup('infra.controller_configuration.enforce_defaults', enforce_default=controller_configuration_execution_environments_enforce_defaults , default_value='', omit_value=omit), true) }}"
pull: "{{ __execution_environments_item.pull | default(lookup('infra.controller_configuration.enforce_defaults', enforce_default=controller_configuration_execution_environments_enforce_defaults , default_value='missing', omit_value=omit), true) }}"
organization: "{{ __execution_environments_item.organization.name | default(__execution_environments_item.organization | default(( '' if controller_configuration_execution_environments_enforce_defaults else omit), true)) }}"
credential: "{{ __execution_environments_item.credential | default(( '' if controller_configuration_execution_environments_enforce_defaults else omit), true) }}"
pull: "{{ __execution_environments_item.pull | default(( 'missing' if controller_configuration_execution_environments_enforce_defaults else omit), true) }}"
state: "{{ __execution_environments_item.state | default(controller_state | default('present')) }}"

# Role specific options
Expand Down
12 changes: 6 additions & 6 deletions roles/groups/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
group:
name: "{{ controller_groups_item.name | mandatory }}"
new_name: "{{ controller_groups_item.new_name | default(omit, true) }}"
description: "{{ controller_groups_item.description | default(lookup('infra.controller_configuration.enforce_defaults', enforce_default=controller_configuration_groups_enforce_defaults , default_value='', omit_value=omit), true) }}"
description: "{{ controller_groups_item.description | default(( '' if controller_configuration_groups_enforce_defaults else omit), true) }}"
inventory: "{{ controller_groups_item.inventory | mandatory }}"
variables: "{{ controller_groups_item.variables | default(lookup('infra.controller_configuration.enforce_defaults', enforce_default=controller_configuration_groups_enforce_defaults , default_value={}, omit_value=omit), true) | regex_replace('[ ]{2,}', '') }}"
hosts: "{{ controller_groups_item.hosts | default(lookup('infra.controller_configuration.enforce_defaults', enforce_default=controller_configuration_groups_enforce_defaults , default_value=[], omit_value=omit), true) }}"
children: "{{ controller_groups_item.children | default(lookup('infra.controller_configuration.enforce_defaults', enforce_default=controller_configuration_groups_enforce_defaults , default_value=[], omit_value=omit), true) }}"
preserve_existing_hosts: "{{ controller_groups_item.preserve_existing_hosts | default(lookup('infra.controller_configuration.enforce_defaults', enforce_default=controller_configuration_groups_enforce_defaults , default_value=false, omit_value=omit)) }}"
preserve_existing_children: "{{ controller_groups_item.preserve_existing_children | default(lookup('infra.controller_configuration.enforce_defaults', enforce_default=controller_configuration_groups_enforce_defaults , default_value=false, omit_value=omit)) }}"
variables: "{{ controller_groups_item.variables | default(( {} if controller_configuration_groups_enforce_defaults else omit), true) | regex_replace('[ ]{2,}', '') }}"
hosts: "{{ controller_groups_item.hosts | default(( [] if controller_configuration_groups_enforce_defaults else omit), true) }}"
children: "{{ controller_groups_item.children | default(( [] if controller_configuration_groups_enforce_defaults else omit), true) }}"
preserve_existing_hosts: "{{ controller_groups_item.preserve_existing_hosts | default(( false if controller_configuration_groups_enforce_defaults else omit)) }}"
preserve_existing_children: "{{ controller_groups_item.preserve_existing_children | default(( false if controller_configuration_groups_enforce_defaults else omit)) }}"
state: "{{ controller_groups_item.state | default(controller_state | default('present')) }}"

# Role Standard Options
Expand Down
6 changes: 3 additions & 3 deletions roles/hosts/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
host:
name: "{{ __controller_host_item.name | mandatory }}"
new_name: "{{ __controller_host_item.new_name | default(omit, true) }}"
description: "{{ __controller_host_item.description | default(lookup('infra.controller_configuration.enforce_defaults', enforce_default=controller_configuration_host_enforce_defaults , default_value='', omit_value=omit), true) }}"
description: "{{ __controller_host_item.description | default(( '' if controller_configuration_host_enforce_defaults else omit), true) }}"
inventory: "{{ __controller_host_item.inventory | mandatory }}"
enabled: "{{ __controller_host_item.enabled | default(lookup('infra.controller_configuration.enforce_defaults', enforce_default=controller_configuration_host_enforce_defaults , default_value=true, omit_value=omit), true) }}"
enabled: "{{ __controller_host_item.enabled | default(( false if controller_configuration_host_enforce_defaults else omit), true) }}"
state: "{{ __controller_host_item.state | default(controller_state | default('present')) }}"
variables: "{{ __controller_host_item.variables | default(lookup('infra.controller_configuration.enforce_defaults', enforce_default=controller_configuration_host_enforce_defaults , default_value={}, omit_value=omit), true) | regex_replace('[ ]{2,}', '') }}"
variables: "{{ __controller_host_item.variables | default(( {} if controller_configuration_host_enforce_defaults else omit), true) | regex_replace('[ ]{2,}', '') }}"

# Role Standard Options
controller_host: "{{ controller_hostname | default(omit, true) }}"
Expand Down
Loading

0 comments on commit 71a5247

Please sign in to comment.