-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
813 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
minor_changes: | ||
- Add a hostgroups role (https://github.com/theforeman/foreman-ansible-modules/issues/1116) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
theforeman.foreman.hostgroups | ||
============================= | ||
|
||
This role creates and manages Hostgroups. | ||
|
||
Role Variables | ||
-------------- | ||
|
||
This role supports the [Common Role Variables](https://github.com/theforeman/foreman-ansible-modules/blob/develop/README.md#common-role-variables). | ||
|
||
- `foreman_hostgroups`: List of hostgroups to manage that are each represented as a dictionary. See module documentation for a list of available options for each hostgroup. | ||
Hostgroups may have any set of fields defined on them and may optionally define a `parent` for nested hostgroups. | ||
A variety of examples are demonstrated in the data structure below: | ||
|
||
```yaml | ||
foreman_hostgroups: | ||
- name: "Basic example" | ||
architecture: "x86_64" | ||
operatingsystem: "CentOS" | ||
medium: "media_name" | ||
ptable: "partition_table_name" | ||
- name: "Proxies hostgroup" | ||
environment: production | ||
puppet_proxy: puppet-proxy.example.com | ||
puppet_ca_proxy: puppet-proxy.example.com | ||
openscap_proxy: openscap-proxy.example.com | ||
- name: "CentOS 7" | ||
organization: "Default Organization" | ||
lifecycle_environment: "Production" | ||
content_view: "CentOS 7" | ||
activation_keys: centos-7 | ||
- name: "Webserver" | ||
parent: "CentOS 7" | ||
environment: production | ||
puppet_proxy: puppet-proxy.example.com | ||
puppet_ca_proxy: puppet-proxy.example.com | ||
openscap_proxy: openscap-proxy.example.com | ||
``` | ||
Example Playbooks | ||
----------------- | ||
This example creates several hostgroups with some nested examples. | ||
```yaml | ||
- hosts: localhost | ||
roles: | ||
- role: theforeman.foreman.hostgroups | ||
vars: | ||
foreman_server_url: https://foreman.example.com | ||
foreman_username: "admin" | ||
foreman_password: "changeme" | ||
foreman_hostgroups: | ||
- name: "Basic example" | ||
architecture: "x86_64" | ||
operatingsystem: "CentOS" | ||
medium: "media_name" | ||
ptable: "partition_table_name" | ||
- name: "Proxies hostgroup" | ||
environment: production | ||
puppet_proxy: puppet-proxy.example.com | ||
puppet_ca_proxy: puppet-proxy.example.com | ||
openscap_proxy: openscap-proxy.example.com | ||
- name: "CentOS 7" | ||
organization: "Default Organization" | ||
lifecycle_environment: "Production" | ||
content_view: "CentOS 7" | ||
activation_keys: centos-7 | ||
- name: "Webserver" | ||
parent: "CentOS 7" | ||
environment: production | ||
puppet_proxy: puppet-proxy.example.com | ||
puppet_ca_proxy: puppet-proxy.example.com | ||
openscap_proxy: openscap-proxy.example.com | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
- name: 'Create Hostgroups' | ||
theforeman.foreman.hostgroup: | ||
username: "{{ foreman_username | default(omit) }}" | ||
password: "{{ foreman_password | default(omit) }}" | ||
server_url: "{{ foreman_server_url | default(omit) }}" | ||
validate_certs: "{{ validate_certs | default(omit) }}" | ||
name: "{{ item.name }}" | ||
updated_name: "{{ item.updated_name | default(omit) }}" | ||
description: "{{ item.description | default(omit) }}" | ||
parent: "{{ item.parent | default(omit) }}" | ||
organization: "{{ item.organization | default(omit) }}" | ||
organizations: "{{ item.organizations | default(omit) }}" | ||
locations: "{{ item.locations | default(omit) }}" | ||
architecture: "{{ item.architecture | default(omit) }}" | ||
operatingsystem: "{{ item.operatingsystem | default(omit) }}" | ||
medium: "{{ item.medium | default(omit) }}" | ||
ptable: "{{ item.ptable | default(omit) }}" | ||
parameters: "{{ item.parameters | default(omit) }}" | ||
ansible_roles: "{{ item.ansible_roles | default(omit) }}" | ||
compute_resource: "{{ item.compute_resource | default(omit) }}" | ||
compute_profile: "{{ item.compute_profile | default(omit) }}" | ||
domain: "{{ item.domain | default(omit) }}" | ||
subnet: "{{ item.subnet | default(omit) }}" | ||
subnet6: "{{ item.subnet6 | default(omit) }}" | ||
root_pass: "{{ item.root_pass | default(omit) }}" | ||
realm: "{{ item.realm | default(omit) }}" | ||
pxe_loader: "{{ item.pxe_loader | default(omit) }}" | ||
environment: "{{ item.environment | default(omit) }}" | ||
puppetclasses: "{{ item.puppetclasses | default(omit) }}" | ||
config_groups: "{{ item.config_groups | default(omit) }}" | ||
puppet_proxy: "{{ item.puppet_proxy | default(omit) }}" | ||
puppet_ca_proxy: "{{ item.puppet_ca_proxy | default(omit) }}" | ||
openscap_proxy: "{{ item.openscap_proxy | default(omit) }}" | ||
content_source: "{{ item.content_source | default(omit) }}" | ||
lifecycle_environment: "{{ item.lifecycle_environment | default(omit) }}" | ||
kickstart_repository: "{{ item.kickstart_repository | default(omit) }}" | ||
content_view: "{{ item.content_view | default(omit) }}" | ||
activation_keys: "{{ item.activation_keys | default(omit) }}" | ||
state: "{{ item.state | default(omit) }}" | ||
with_items: | ||
- "{{ foreman_hostgroups }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
foreman.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
interactions: | ||
- request: | ||
body: null | ||
headers: | ||
Accept: | ||
- application/json;version=2 | ||
Accept-Encoding: | ||
- gzip, deflate | ||
Connection: | ||
- keep-alive | ||
User-Agent: | ||
- apypie (https://github.com/Apipie/apypie) | ||
method: GET | ||
uri: https://foreman.example.org/api/status | ||
response: | ||
body: | ||
string: '{"result":"ok","status":200,"version":"2.4.0-develop","api_version":2}' | ||
headers: | ||
Cache-Control: | ||
- max-age=0, private, must-revalidate | ||
Connection: | ||
- Keep-Alive | ||
Content-Security-Policy: | ||
- 'default-src ''self''; child-src ''self''; connect-src ''self'' ws: wss:; | ||
img-src ''self'' data:; script-src ''unsafe-eval'' ''unsafe-inline'' ''self''; | ||
style-src ''unsafe-inline'' ''self''' | ||
Content-Type: | ||
- application/json; charset=utf-8 | ||
Foreman_api_version: | ||
- '2' | ||
Foreman_current_location: | ||
- ; ANY | ||
Foreman_current_organization: | ||
- ; ANY | ||
Foreman_version: | ||
- 2.4.0-develop | ||
Keep-Alive: | ||
- timeout=15, max=100 | ||
Strict-Transport-Security: | ||
- max-age=631139040; includeSubdomains | ||
Vary: | ||
- Accept-Encoding | ||
X-Content-Type-Options: | ||
- nosniff | ||
X-Download-Options: | ||
- noopen | ||
X-Frame-Options: | ||
- sameorigin | ||
X-Permitted-Cross-Domain-Policies: | ||
- none | ||
X-XSS-Protection: | ||
- 1; mode=block | ||
content-length: | ||
- '70' | ||
status: | ||
code: 200 | ||
message: OK | ||
- request: | ||
body: null | ||
headers: | ||
Accept: | ||
- application/json;version=2 | ||
Accept-Encoding: | ||
- gzip, deflate | ||
Connection: | ||
- keep-alive | ||
User-Agent: | ||
- apypie (https://github.com/Apipie/apypie) | ||
method: GET | ||
uri: https://foreman.example.org/api/hostgroups?search=title%3D%22Hostgroup1%22&per_page=4294967296 | ||
response: | ||
body: | ||
string: "{\n \"total\": 0,\n \"subtotal\": 0,\n \"page\": 1,\n \"per_page\"\ | ||
: 4294967296,\n \"search\": \"title=\\\"Hostgroup1\\\"\",\n \"sort\": {\n\ | ||
\ \"by\": null,\n \"order\": null\n },\n \"results\": []\n}\n" | ||
headers: | ||
Cache-Control: | ||
- max-age=0, private, must-revalidate | ||
Connection: | ||
- Keep-Alive | ||
Content-Security-Policy: | ||
- 'default-src ''self''; child-src ''self''; connect-src ''self'' ws: wss:; | ||
img-src ''self'' data:; script-src ''unsafe-eval'' ''unsafe-inline'' ''self''; | ||
style-src ''unsafe-inline'' ''self''' | ||
Content-Type: | ||
- application/json; charset=utf-8 | ||
Foreman_api_version: | ||
- '2' | ||
Foreman_current_location: | ||
- ; ANY | ||
Foreman_current_organization: | ||
- ; ANY | ||
Foreman_version: | ||
- 2.4.0-develop | ||
Keep-Alive: | ||
- timeout=15, max=99 | ||
Strict-Transport-Security: | ||
- max-age=631139040; includeSubdomains | ||
Vary: | ||
- Accept-Encoding | ||
X-Content-Type-Options: | ||
- nosniff | ||
X-Download-Options: | ||
- noopen | ||
X-Frame-Options: | ||
- sameorigin | ||
X-Permitted-Cross-Domain-Policies: | ||
- none | ||
X-XSS-Protection: | ||
- 1; mode=block | ||
content-length: | ||
- '177' | ||
status: | ||
code: 200 | ||
message: OK | ||
- request: | ||
body: '{"hostgroup": {"name": "Hostgroup1"}}' | ||
headers: | ||
Accept: | ||
- application/json;version=2 | ||
Accept-Encoding: | ||
- gzip, deflate | ||
Connection: | ||
- keep-alive | ||
Content-Length: | ||
- '37' | ||
Content-Type: | ||
- application/json | ||
User-Agent: | ||
- apypie (https://github.com/Apipie/apypie) | ||
method: POST | ||
uri: https://foreman.example.org/api/hostgroups | ||
response: | ||
body: | ||
string: '{"subnet_id":null,"subnet_name":null,"operatingsystem_id":null,"operatingsystem_name":null,"domain_id":null,"domain_name":null,"environment_id":null,"environment_name":null,"compute_profile_id":null,"compute_profile_name":null,"ancestry":null,"parent_id":null,"parent_name":null,"ptable_id":null,"ptable_name":null,"medium_id":null,"medium_name":null,"pxe_loader":null,"subnet6_id":null,"subnet6_name":null,"compute_resource_id":null,"compute_resource_name":null,"architecture_id":null,"architecture_name":null,"realm_id":null,"realm_name":null,"created_at":"2020-12-22 | ||
15:01:20 UTC","updated_at":"2020-12-22 15:01:20 UTC","id":1,"name":"Hostgroup1","title":"Hostgroup1","description":null,"puppet_proxy_id":null,"puppet_proxy_name":null,"puppet_ca_proxy_id":null,"puppet_ca_proxy_name":null,"puppet_proxy":null,"puppet_ca_proxy":null,"inherited_compute_profile_id":null,"inherited_environment_id":null,"inherited_domain_id":null,"inherited_puppet_proxy_id":null,"inherited_puppet_ca_proxy_id":null,"inherited_compute_resource_id":null,"inherited_operatingsystem_id":null,"inherited_architecture_id":null,"inherited_medium_id":null,"inherited_ptable_id":null,"inherited_subnet_id":null,"inherited_subnet6_id":null,"inherited_realm_id":null,"inherited_pxe_loader":null,"parameters":[],"template_combinations":[],"puppetclasses":[],"config_groups":[],"all_puppetclasses":[],"locations":[{"id":2,"name":"Default | ||
Location","title":"Default Location","description":null}],"organizations":[]}' | ||
headers: | ||
Cache-Control: | ||
- max-age=0, private, must-revalidate | ||
Connection: | ||
- Keep-Alive | ||
Content-Security-Policy: | ||
- 'default-src ''self''; child-src ''self''; connect-src ''self'' ws: wss:; | ||
img-src ''self'' data:; script-src ''unsafe-eval'' ''unsafe-inline'' ''self''; | ||
style-src ''unsafe-inline'' ''self''' | ||
Content-Type: | ||
- application/json; charset=utf-8 | ||
Foreman_api_version: | ||
- '2' | ||
Foreman_current_location: | ||
- ; ANY | ||
Foreman_current_organization: | ||
- ; ANY | ||
Foreman_version: | ||
- 2.4.0-develop | ||
Keep-Alive: | ||
- timeout=15, max=98 | ||
Strict-Transport-Security: | ||
- max-age=631139040; includeSubdomains | ||
Transfer-Encoding: | ||
- chunked | ||
X-Content-Type-Options: | ||
- nosniff | ||
X-Download-Options: | ||
- noopen | ||
X-Frame-Options: | ||
- sameorigin | ||
X-Permitted-Cross-Domain-Policies: | ||
- none | ||
X-XSS-Protection: | ||
- 1; mode=block | ||
status: | ||
code: 201 | ||
message: Created | ||
version: 1 |
Oops, something went wrong.