diff --git a/roles/host_collections/README.md b/roles/host_collections/README.md new file mode 100644 index 0000000000..ac1cc5e341 --- /dev/null +++ b/roles/host_collections/README.md @@ -0,0 +1,42 @@ +theforeman.foreman.foreman_host_collections +============================= + +This role creates and manages Host Collections. + +Role Variables +-------------- + +This role supports the [Common Role Variables](https://github.com/theforeman/foreman-ansible-modules/blob/develop/README.md#common-role-variables). + +- `foreman_host_collections`: List of host collections to manage that are each represented as a dictionary. See module documentation for a list of available options for each host collection. + Host collections may have any set of fields defined on them. + A variety of examples are demonstrated in the data structure below: + +```yaml +foreman_host_collections: + - name: "Apache hosts" + description: "All Apache Servers" + organization: "Some Org" + - name: "Foremans" + description: "Foreman Servers" + organization: "Handymen org" +``` + +Example Playbooks +----------------- + +This example creates several host collections. + +```yaml +- hosts: localhost + roles: + - role: theforeman.foreman.host_collections + vars: + foreman_server_url: https://foreman.example.com + foreman_username: "admin" + foreman_password: "changeme" + foreman_host_collections: + - name: "Apache hosts" + description: "All Apache Servers" + organization: "Some Org" +``` diff --git a/roles/host_collections/meta/main.yml b/roles/host_collections/meta/main.yml new file mode 100644 index 0000000000..0f177d1ddb --- /dev/null +++ b/roles/host_collections/meta/main.yml @@ -0,0 +1,4 @@ +--- +galaxy_info: + description: Create and manage Host Collections + standalone: false diff --git a/roles/host_collections/tasks/main.yml b/roles/host_collections/tasks/main.yml new file mode 100644 index 0000000000..75b4a7fa6f --- /dev/null +++ b/roles/host_collections/tasks/main.yml @@ -0,0 +1,14 @@ +--- +- name: 'Create Host Collections' # noqa: args[module] + theforeman.foreman.host_collection: + username: "{{ foreman_username | default(omit) }}" + password: "{{ foreman_password | default(omit) }}" + server_url: "{{ foreman_server_url | default(omit) }}" + validate_certs: "{{ foreman_validate_certs | default(omit) }}" + name: "{{ item.name }}" + updated_name: "{{ item.updated_name | default(omit) }}" + description: "{{ item.description | default(omit) }}" + organization: "{{ item.organization | default(omit) }}" + state: "{{ item.state | default(omit) }}" + with_items: + - "{{ foreman_host_collections }}"