Skip to content
Open
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
15 changes: 14 additions & 1 deletion plugins/modules/content_view.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@
- A rolling content view contains latest synced state of repositories.
type: bool
version_added: 5.5.0
lifecycle_environments:
description:
- List of lifecycle environments that content of this rolling content view will be promoted to.
- Ignored if I(rolling=False).
required: False
type: list
elements: str
version_added: 5.5.0
composite:
description:
- A composite view contains other content views.
Expand Down Expand Up @@ -192,6 +200,7 @@ def main():
solve_dependencies=dict(type='bool'),
import_only=dict(type='bool'),
components=dict(type='nested_list', foreman_spec=cvc_foreman_spec, resolve=False),
lifecycle_environments=dict(type='entity_list', flat_name='environment_ids'),
repositories=dict(type='entity_list', elements='dict', resolve=False, options=dict(
name=dict(required=True),
product=dict(required=True),
Expand All @@ -200,7 +209,7 @@ def main():
argument_spec=dict(
state=dict(default='present', choices=['present_with_defaults', 'present', 'absent']),
),
mutually_exclusive=[['repositories', 'components']],
mutually_exclusive=[['repositories', 'components'], ['lifecycle_environments', 'components']],
entity_opts=dict(thin=False),
)

Expand All @@ -226,6 +235,10 @@ def main():
repositories.append(module.find_resource_by_name('repositories', repository['name'], params={'product_id': product['id']}, thin=True))
module.foreman_params['repositories'] = repositories

if 'lifecycle_environments' in module.foreman_params:
if module.foreman_params['rolling'] is not True:
module.fail_json(msg="Lifecycle Environments can only be specified for Rolling Content View.")

if entity and module.desired_absent:
for lce in entity.get('environments', []):
module.resource_action('content_views', 'remove_from_environment', {'id': entity['id'], 'environment_id': lce['id']})
Expand Down
2 changes: 2 additions & 0 deletions roles/content_views/tasks/_create_content_view.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
auto_publish: "{{ content_view.auto_publish | default(omit) }}"
components: "{{ content_view.components | default(omit) }}"
composite: "{{ content_view.components | default(content_view.composite) | default(false) | ternary(true, false) }}"
rolling: "{{ content_view.rolling | default(false) }}"
lifecycle_environments: "{{ content_view.lifecycle_environments | default(omit) }}"
description: "{{ content_view.description | default(omit) }}"
label: "{{ content_view.label | default(omit) }}"
repositories: "{{ content_view.repositories | default(omit) }}"
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/apidoc/katello.json

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions tests/test_playbooks/content_view.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,22 @@
vars:
product_name: "Test Product 2"
repository_state: present
- include_tasks: tasks/lifecycle_environment.yml
vars:
lifecycle_environment_state: present
lifecycle_environment_name: "{{ item.name }}"
lifecycle_environment_label: "{{ item.label }}"
lifecycle_environment_prior: "{{ item.prior }}"
loop:
- name: Test
label: test
prior: Library
- name: QA
label: qa
prior: Test
- name: Prod
label: prod
prior: QA
- include_tasks: tasks/content_view.yml
vars:
content_view_name: "Test Composite Content View"
Expand Down Expand Up @@ -214,6 +230,10 @@
vars:
content_view_state: present
expected_change: true
lifecycle_environments:
- QA
- Test
- Prod
rolling: true
repositories:
- name: "Test Repository"
Expand All @@ -225,6 +245,10 @@
vars:
content_view_state: present
expected_change: false
lifecycle_environments:
- QA
- Prod
- Test
rolling: true
repositories:
- name: "Test Repository"
Expand All @@ -233,6 +257,10 @@
vars:
content_view_state: absent
expected_change: true
lifecycle_environments:
- Test
- QA
- Prod
rolling: true
repositories:
- name: "Test Repository"
Expand Down
Loading
Loading