Skip to content

Commit

Permalink
Katello content_views: add CV and CCV (#150)
Browse files Browse the repository at this point in the history
Implements Katello (Composite) Content Views.
Tested with Foreman 3.7 / Katello 4.9 for Creation/Update/Deletion.

Refs #140

Signed-off-by: Dominik Pataky <[email protected]>
  • Loading branch information
bitkeks authored Jan 29, 2024
1 parent f92a79f commit 90bbf74
Show file tree
Hide file tree
Showing 7 changed files with 967 additions and 1 deletion.
39 changes: 39 additions & 0 deletions docs/data-sources/foreman_katello_content_view.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

# foreman_katello_content_view


(Composite) Content Views create an abstract view on a collection of repositories and allow versioning of these views. Additional fine tuning can be done with package filters.


## Example Usage

```
# Autogenerated example with required keys
data "foreman_katello_content_view" "example" {
name = "my content view"
}
```


## Argument Reference

The following arguments are supported:

- `name` - (Required) Name of the content view.


## Attributes Reference

The following attributes are exported:

- `auto_publish` - Relevant for Composite Content Views: 'Automatically publish a new version of the composite content view whenever one of its content views is published. Autopublish will only happen for component views that use the 'Always use latest version' option.'
- `component_ids` - Relevant for CCVs: list of CV IDs.
- `composite` - Is this Content View a Composite CV?
- `description` - Description for the (composite) content view
- `filter` - Content view filters and their rules. Currently read-only, to be used as data source
- `label` - Label for the (composite) content view. Cannot be changed after creation. By default set to the name, with underscores as spaces replacement.
- `name` - Name of the content view.
- `organization_id` -
- `repository_ids` - List of repository IDs.
- `solve_dependencies` - Relevant for Content Views: 'This will solve RPM and module stream dependencies on every publish of this content view. Dependency solving significantly increases publish time (publishes can take over three times as long) and filters will be ignored when adding packages to solve dependencies. Also, certain scenarios involving errata may still cause dependency errors.'

50 changes: 50 additions & 0 deletions docs/resources/foreman_katello_content_view.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@

# foreman_katello_content_view


(Composite) Content Views create an abstract view on a collection of repositories and allow versioning of these views. Additional fine tuning can be done with package filters.


## Example Usage

```
# Autogenerated example with required keys
resource "foreman_katello_content_view" "example" {
component_ids = [1, 4]
composite = false
name = "My new CV"
repository_ids = [1, 4, 5]
}
```


## Argument Reference

The following arguments are supported:

- `auto_publish` - (Optional) Relevant for Composite Content Views: 'Automatically publish a new version of the composite content view whenever one of its content views is published. Autopublish will only happen for component views that use the 'Always use latest version' option.'
- `component_ids` - (Optional) Relevant for CCVs: list of CV IDs.
- `composite` - (Optional) Is this Content View a Composite CV?
- `description` - (Optional) Description for the (composite) content view
- `label` - (Optional, Force New) Label for the (composite) content view. Cannot be changed after creation. By default set to the name, with underscores as spaces replacement.
- `name` - (Required) Name of the (composite) content view.
- `organization_id` - (Optional)
- `repository_ids` - (Optional) List of repository IDs.
- `solve_dependencies` - (Optional) Relevant for Content Views: 'This will solve RPM and module stream dependencies on every publish of this content view. Dependency solving significantly increases publish time (publishes can take over three times as long) and filters will be ignored when adding packages to solve dependencies. Also, certain scenarios involving errata may still cause dependency errors.'


## Attributes Reference

The following attributes are exported:

- `auto_publish` - Relevant for Composite Content Views: 'Automatically publish a new version of the composite content view whenever one of its content views is published. Autopublish will only happen for component views that use the 'Always use latest version' option.'
- `component_ids` - Relevant for CCVs: list of CV IDs.
- `composite` - Is this Content View a Composite CV?
- `description` - Description for the (composite) content view
- `filter` - Content view filters and their rules. Currently read-only, to be used as data source
- `label` - Label for the (composite) content view. Cannot be changed after creation. By default set to the name, with underscores as spaces replacement.
- `name` - Name of the (composite) content view.
- `organization_id` -
- `repository_ids` - List of repository IDs.
- `solve_dependencies` - Relevant for Content Views: 'This will solve RPM and module stream dependencies on every publish of this content view. Dependency solving significantly increases publish time (publishes can take over three times as long) and filters will be ignored when adding packages to solve dependencies. Also, certain scenarios involving errata may still cause dependency errors.'

27 changes: 27 additions & 0 deletions examples/content_view/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Simple Content View data source
data "foreman_katello_content_view" "ubuntu2204" {
name = "Ubuntu 22.04"
}

// Query a repository to use its ID in the Content View
data "foreman_katello_repository" "ubuntu2204" {
name = "Ubuntu 22.04"
}

// Create a new Content View with one repository and one filter
resource "foreman_katello_content_view" "test_cv_write" {
name = "Test CV for Ubuntu Sec"
repository_ids = [data.foreman_katello_repository.ubuntu2204.id]
composite = false

filter {
name = "my filter 1"
type = "deb"
inclusion = true
description = "Filters all packages except those with name 'testfilter-*'"

rule {
name = "testfilter-*"
}
}
}
Loading

0 comments on commit 90bbf74

Please sign in to comment.