-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP - create a playbook to gather all possibile information from Sate…
…llite It's more a proof of concept on how to use the theforeman.foreman.resource_info module, and it's very early but exactly the difficulty to properly use the module makes the exercise interesting to have a show-case on how to properly use it.
- Loading branch information
Showing
4 changed files
with
199 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,117 @@ | ||
--- | ||
# Example of usage to create all the VMs in the inventory, without | ||
# setting up again the libvirt host: | ||
# ansible-playbook -i inventory libvirt_domain_create.yml --tags virtual_machines -K | ||
|
||
- name: setup the libvirt hosts for libvirt automation | ||
hosts: satellites | ||
gather_facts: false | ||
|
||
vars: | ||
satinfo_full_details: false | ||
|
||
tasks: | ||
|
||
- name: get primary type of information from Satellite | ||
theforeman.foreman.resource_info: | ||
full_details: "{{ item.full_details | default(satinfo_full_details) }}" | ||
organization: "{{ item.organization | default(omit) }}" # not all queries accept scoping | ||
params: "{{ item.params | default(omit) }}" # not all queries accept params | ||
search: "{{ item.search | default(omit) }}" | ||
resource: "{{ item.name }}" | ||
server_url: "{{ satellite_server_url | default('https://' + inventory_hostname) }}" # hopefully defined by FOREMAN_SERVER_URL | ||
username: "{{ satellite_username | default(omit) }}" # hopefully defined by FOREMAN_USERNAME | ||
password: "{{ satellite_password | default(omit) }}" # hopefully defined by FOREMAN_PASSWORD | ||
validate_certs: "{{ satellite_validate_certs | default(omit) }}" # hopefully defined by FOREMAN_VALIDATE_CERTS | ||
loop: | ||
- name: ansible_collections | ||
- name: ansible_roles | ||
- name: ansible_variables | ||
- name: architectures | ||
- name: arf_reports | ||
- name: audits | ||
- name: auth_source_externals | ||
- name: auth_source_internals | ||
- name: auth_source_ldaps | ||
- name: auth_sources | ||
- name: bookmarks | ||
- name: capsules | ||
- name: common_parameters | ||
- name: compute_profiles | ||
- name: compute_resources | ||
- name: config_groups | ||
- name: config_reports | ||
- name: configs | ||
- name: content_view_versions | ||
- name: content_views | ||
- name: debs | ||
- name: discovered_hosts | ||
- name: discovery_rules | ||
- name: docker_manifest_lists | ||
- name: docker_manifests | ||
- name: docker_tags | ||
- name: domains | ||
- name: environments | ||
#TODO- name: errata # takes some time | ||
- name: fact_values | ||
- name: file_units | ||
- name: filters | ||
- name: foreman_tasks | ||
- name: host_collections | ||
- name: hostgroups | ||
- name: hosts | ||
- name: http_proxies | ||
- name: job_invocations | ||
- name: job_templates | ||
- name: lifecycle_environments | ||
- name: locations | ||
- name: mail_notifications | ||
- name: media | ||
- name: models | ||
- name: module_streams | ||
- name: operatingsystems | ||
- name: organizations | ||
- name: ostree_branches | ||
- name: package_groups | ||
#TODO- name: packages # takes a long time | ||
- name: permissions | ||
- name: plugins | ||
- name: policies | ||
- name: provisioning_templates | ||
- name: ptables | ||
- name: puppet_modules | ||
- name: puppetclasses | ||
- name: realms | ||
- name: recurring_logics | ||
- name: remote_execution_features | ||
- name: report_templates | ||
- name: repositories | ||
- name: roles | ||
- name: scap_content_profiles | ||
- name: scap_contents | ||
- name: settings | ||
- name: smart_class_parameters | ||
- name: smart_proxies | ||
- name: srpms | ||
- name: subnets | ||
- name: subscriptions | ||
- name: tailoring_files | ||
- name: template_kinds | ||
- name: trends | ||
- name: usergroups | ||
- name: users | ||
register: __satinfo_primary_res | ||
- name: output the gathered Satellite information | ||
debug: | ||
var: __satinfo_primary_res | ||
|
||
# FIXME: what about 'registries' listed in the module examples? Error: Satellite doesn't know about those | ||
|
||
- name: get secondary type of information from Satellite | ||
include_tasks: | ||
file: tasks/sat_info_secondary.yml | ||
loop_control: | ||
loop_var: __satinfo_primary_item | ||
loop: | ||
- organizations | ||
- smart_proxies |
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,24 @@ | ||
--- | ||
|
||
- name: get secondary type of information from Satellite | ||
theforeman.foreman.resource_info: | ||
full_details: "{{ item.full_details | default(satinfo_full_details) }}" | ||
organization: "{{ item.organization | default(omit) }}" # not all queries accept scoping | ||
params: "{{ {'organization_id': __satinfo_secondary_item.id} | combine (item.params | default({})) }}" | ||
search: "{{ item.search | default(omit) }}" | ||
resource: "{{ item.name }}" | ||
server_url: "{{ satellite_server_url | default(omit) }}" # hopefully defined by FOREMAN_SERVER_URL | ||
username: "{{ satellite_username | default(omit) }}" # hopefully defined by FOREMAN_USERNAME | ||
password: "{{ satellite_password | default(omit) }}" # hopefully defined by FOREMAN_PASSWORD | ||
validate_certs: "{{ satellite_validate_certs | default(omit) }}" # hopefully defined by FOREMAN_VALIDATE_CERTS | ||
loop: | ||
- name: activation_keys | ||
- name: content_credentials | ||
- name: gpg_keys | ||
- name: products | ||
- name: sync_plans | ||
# - name: upstream_subscriptions # HTTPError: 400 Client Error: Bad Request | ||
register: __satinfo_organizations_res | ||
- name: output the gathered Satellite information | ||
debug: | ||
var: __satinfo_organizations_res |
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,10 @@ | ||
--- | ||
- name: get secondary type of information from Satellite ({{ __satinfo_primary_item }}) | ||
include_tasks: | ||
file: tasks/sat_info_{{ __satinfo_primary_item }}.yml | ||
loop_control: | ||
label: "{{ __satinfo_secondary_item.name }}" | ||
loop_var: __satinfo_secondary_item | ||
loop: "{{ __satinfo_primary_res | json_query(__satinfo_js_query) }}" | ||
vars: | ||
__satinfo_js_query: "results[?item.name == '{{ __satinfo_primary_item }}'].resources[]" |
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,48 @@ | ||
--- | ||
|
||
- name: get secondary type of information from Satellite (smart_proxies) | ||
theforeman.foreman.resource_info: | ||
full_details: "{{ item.full_details | default(satinfo_full_details) }}" | ||
organization: "{{ item.organization | default(omit) }}" # not all queries accept scoping | ||
params: "{{ {'smart_proxy_id': __satinfo_secondary_item.id} | combine (item.params | default({})) }}" | ||
search: "{{ item.search | default(omit) }}" | ||
resource: "{{ item.name }}" | ||
server_url: "{{ satellite_server_url | default(omit) }}" # hopefully defined by FOREMAN_SERVER_URL | ||
username: "{{ satellite_username | default(omit) }}" # hopefully defined by FOREMAN_USERNAME | ||
password: "{{ satellite_password | default(omit) }}" # hopefully defined by FOREMAN_PASSWORD | ||
validate_certs: "{{ satellite_validate_certs | default(omit) }}" # hopefully defined by FOREMAN_VALIDATE_CERTS | ||
loop: | ||
- name: autosign # KeyError: \"missing param 'smart_proxy_id' in parameters\"" | ||
register: __satinfo_smart_proxies_res | ||
- name: output the gathered Satellite information (smart_proxies) | ||
debug: | ||
var: __satinfo_smart_proxies_res | ||
|
||
# - name: compute_attributes # KeyError: \"missing param 'compute_resource_id' in parameters\"" | ||
# - name: content_view_components # MissingArgumentsError: The following required parameters are missing: composite_content_view_id" | ||
# - name: content_view_filter_rules # MissingArgumentsError: The following required parameters are missing: content_view_filter_id" | ||
# - name: content_view_filters # MissingArgumentsError: The following required parameters are missing: content_view_id" | ||
# - name: content_view_puppet_modules # MissingArgumentsError: The following required parameters are missing: content_view_id" | ||
# - name: external_usergroups # MissingArgumentsError: The following required parameters are missing: usergroup_id" | ||
# - name: foreign_input_sets # MissingArgumentsError: The following required parameters are missing: template_id" | ||
# - name: template_inputs # MissingArgumentsError: The following required parameters are missing: template_id" | ||
# - name: host_classes # KeyError: \"missing param 'host_id' in parameters\"" | ||
# - name: host_debs # MissingArgumentsError: The following required parameters are missing: host_id" | ||
# - name: host_errata # MissingArgumentsError: The following required parameters are missing: host_id" | ||
# - name: host_module_streams # MissingArgumentsError: The following required parameters are missing: host_id" | ||
# - name: host_packages # MissingArgumentsError: The following required parameters are missing: host_id" | ||
# - name: host_subscriptions # MissingArgumentsError: The following required parameters are missing: host_id" | ||
# - name: host_tracer # MissingArgumentsError: The following required parameters are missing: host_id" | ||
# - name: interfaces # MissingArgumentsError: The following required parameters are missing: host_id" | ||
# - name: hostgroup_classes # KeyError: \"missing param 'hostgroup_id' in parameters\"" | ||
# - name: images # KeyError: \"missing param 'operatingsystem_id' in parameters\"" | ||
# - name: os_default_templates # KeyError: \"missing param 'provisioning_template_id' in parameters\"" | ||
# - name: template_combinations # KeyError: \"missing param 'provisioning_template_id' in parameters\"" | ||
# - name: override_values # KeyError: \"missing param 'smart_class_parameter_id' in parameters\"" | ||
# - name: parameters # KeyError: \"missing param 'subnet_id' in parameters\"" | ||
# - name: personal_access_tokens # MissingArgumentsError: The following required parameters are missing: user_id" | ||
# - name: ssh_keys # MissingArgumentsError: The following required parameters are missing: user_id" | ||
# - name: table_preferences # KeyError: \"missing param 'user_id' in parameters\"" | ||
# - name: sync # KeyError: \"missing param 'repository_id' in parameters\"" | ||
# - name: content_view_histories # MissingArgumentsError: The following required parameters are missing: id" | ||
# - name: tasks # KeyError: \"missing param 'id' in parameters\"" |