Broken update
This commit is contained in:
54
build_ansible.yml
Normal file
54
build_ansible.yml
Normal file
@@ -0,0 +1,54 @@
|
||||
---
|
||||
- name: VM Provisioning
|
||||
hosts: tag_ansible:&tag_tower:&cluster_ToalLabRHV
|
||||
connection: local
|
||||
|
||||
tasks:
|
||||
- block:
|
||||
- name: Obtain SSO token from username / password credentials
|
||||
redhat.rhv.ovirt_auth:
|
||||
url: "{{ ovirt_url }}"
|
||||
username: "{{ ovirt_username }}"
|
||||
password: "{{ ovirt_password }}"
|
||||
|
||||
- name: Disks Created
|
||||
ovirt_disk:
|
||||
auth: "{{ ovirt_auth }}"
|
||||
description: "Boot Disk for {{ inventory_hostname }}"
|
||||
interface: virtio
|
||||
size: 120GiB
|
||||
storage_domain: nas_iscsi
|
||||
bootable: True
|
||||
wait: true
|
||||
name: "{{ inventory_hostname }}_disk0"
|
||||
state: present
|
||||
|
||||
- name: Add NIC to VM
|
||||
ovirt_nic:
|
||||
state: present
|
||||
vm:
|
||||
name: mynic
|
||||
interface: e1000
|
||||
mac_address: 00:1a:4a:16:01:56
|
||||
profile: ovirtmgmt
|
||||
network: ovirtmgmt
|
||||
|
||||
- name: Plug NIC to VM
|
||||
redhat.rhv.ovirt_nic:
|
||||
state: plugged
|
||||
vm: myvm
|
||||
name: mynic
|
||||
|
||||
|
||||
always:
|
||||
- name: Always revoke the SSO token
|
||||
ovirt_auth:
|
||||
state: absent
|
||||
ovirt_auth: "{{ ovirt_auth }}"
|
||||
|
||||
collections:
|
||||
- redhat.rhv
|
||||
|
||||
# - name: VM Configuration
|
||||
# - name: Automation Platform Installer
|
||||
# - name:
|
||||
30
build_rhel_template.yml
Normal file
30
build_rhel_template.yml
Normal file
@@ -0,0 +1,30 @@
|
||||
---
|
||||
- name: Create Build Host in Satellite
|
||||
hosts: localhost
|
||||
connection: localhost
|
||||
|
||||
tasks:
|
||||
- name: Build Host
|
||||
redhat.satellite.host:
|
||||
architecture: x86_64
|
||||
build: true
|
||||
comment: "RHEL 8 Template"
|
||||
compute_profile: "3-Large"
|
||||
compute_resource: "Home Lab"
|
||||
compute_attributes:
|
||||
cpus: 4
|
||||
memory_mb: 4096
|
||||
content_view: "RHEL8"
|
||||
domain: "sandbox.toal.ca"
|
||||
enabled: true
|
||||
hostgroup: "Lab RHEL Hosts/RHEL 8"
|
||||
kickstart_repository:
|
||||
lifecycle_environment: "Library"
|
||||
location: "Lab"
|
||||
name: "rhel8build.sandbox.toal.ca"
|
||||
operatingsystem: "Red Hat 8.3"
|
||||
organization: "Toal.ca"
|
||||
password: "{{ vault_sat6_pass }}"
|
||||
server_url: "https://sat6.lab.toal.ca/"
|
||||
subnet: "192.168.16.0"
|
||||
username: "{{ vault_sat6_user }}"
|
||||
@@ -11,3 +11,9 @@ collections:
|
||||
|
||||
- name: ovirt.ovirt
|
||||
source: https://galaxy.ansible.com
|
||||
|
||||
- name: redhat.rhv
|
||||
source: https://cloud.redhat.com/api/automation-hub/
|
||||
|
||||
- name: redhat.satellite
|
||||
source: https://cloud.redhat.com/api/automation-hub/
|
||||
|
||||
16
publish_cvs.yml
Normal file
16
publish_cvs.yml
Normal file
@@ -0,0 +1,16 @@
|
||||
---
|
||||
- name: Publish CVs
|
||||
hosts: sat6.lab.toal.ca
|
||||
connection: local
|
||||
|
||||
tasks:
|
||||
- name: Publish Content View
|
||||
redhat.satellite.content_view_version:
|
||||
username: "{{ vault_sat6_user }}"
|
||||
password: "{{ vault_sat6_pass }}"
|
||||
server_url: "https://{{ inventory_hostname }}"
|
||||
validate_certs: false
|
||||
content_view: "RHEL8"
|
||||
organization: "Toal.ca"
|
||||
lifecycle_environments:
|
||||
- Library
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
# Probably want to split this out into a proper certificate management role for Toal.ca
|
||||
- name: Request TLS Certificate from LetsEncrypt
|
||||
hosts: rhv.mgmt.toal.ca
|
||||
hosts: localhost
|
||||
connection: local
|
||||
gather_facts: false
|
||||
# This doesn't belong here
|
||||
@@ -12,6 +12,7 @@
|
||||
root_certificate: https://letsencrypt.org/certs/trustid-x3-root.pem.txt
|
||||
domains:
|
||||
- rhv.mgmt.toal.ca
|
||||
- rhv.lan.toal.ca
|
||||
|
||||
pre_tasks:
|
||||
- name: Ensure Let's Encrypt Account Exists
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018 Andrew J Huffman
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -1,137 +0,0 @@
|
||||
# ahuffman.sat6_create_hosts
|
||||
An Ansible role to create new virtual and bare-metal hosts in Satellite 6.x. v2 of Satellite6 API is required.
|
||||
|
||||
## Role Variables
|
||||
|
||||
|Variable Name|Required|Description|Type|Default|
|
||||
|---|:---:|---|:---:|:---:|
|
||||
|sat6_fqdn|yes|Fully qualified domain name of the Satellite 6 host.|string|""|
|
||||
|sat6_user|yes|Username of the Satellite 6 user that has access to create new hosts.|string|""|
|
||||
|sat6_pass|yes|Password of the Satellite 6 user that has access to create new hosts. This should be vaulted to ensure security.|string|""|
|
||||
|sat6_organization|yes|Satellite6 organization to create the hosts defined in `sat6_hosts`.|string|""|
|
||||
|sat6_fail_on_existing|no|To fail the playbook if any of the hosts defined in `sat6_hosts` already exist in Satellite6. Useful when using notifications in Ansible Tower, and you want to be notified on a failure. True means fail if a host exists, False means just output a summary instead and allows for a more idempotent style run. (i.e. you can run the playbook over and over again and it will only create hosts that don't exist)|boolean|False|
|
||||
|sat6_power_on_delay|no|Seconds to delay between creating a new virtual machine via a compute resource and powering it on (to prevent possible race conditions as the VM is being created in the external system) | integer | 30 |
|
||||
|sat6_hosts|yes|Satellite 6 hosts you would like to create|list of dictionaries|[]|
|
||||
|
||||
## `sat6_hosts` Dictionary Fields - Common
|
||||
Fields you can utilize for either bare-metal or virtual host creation.
|
||||
|
||||
|Field Name|Required|Description|Type|
|
||||
|---|:---:|---|:---:|
|
||||
|name|yes|Hostname of the host to create|string|
|
||||
|comment|no|A comment that will appear in the host's additional information. A short description of what the host is for.|string|
|
||||
|domain|no|Name of the Satellite6 domain to create the host with. Not required if you wish to inherit the host group's default domain, otherwise this overrides the host group default.|string|
|
||||
|host_group|yes|Name of the Satellite6 Host Group to create the new host with. **If nesting Host Groups, this would be the Host Group name in the form `hostgroup1/hostgroup2/hostgroup3`, also known as the `title` in the API.**|string|
|
||||
|ipv4|no|IPv4 address to assign to the host. Not required if the host group is configured to suggest an IPv4 address via ipam or dhcp.|string|
|
||||
|location|yes|Name of the Satellite6 location where you will be deploying the host.|string|
|
||||
|partition_table|no|Name of the Satellite6 partition table to create the host with. Not required if you wish to inherit the host group's default partition table.|string|
|
||||
|subnet|no|Name of the Satellite6 subnet to create the host with. Not required if you wish to inherit the host group's default subnet.|string|
|
||||
|parameters|no|List of additional Satellite6 host specific parameters you would like to set on the host. This is useful when doing post provisioning tasks and wish to use conditionals based off of these values, etc.|list of dictionaries|
|
||||
|register_only|no|Whether to only create the host entry in Satellite6 VS. actually powering it on and provisioning it (Defaults to False). Functionality added for other use-cases than provisioning (i.e. client registration with location specified). If using this method of host creation, you will need to specify compute resources and profiles as they will not be queried from the Host Group.|boolean|
|
||||
|manage_host|no|When using `register_only: True` and `force_host_update: True`, will allow for the Host's build cycle to become managed by Satellite6. Defaults to `False`.
|
||||
|force_host_update|no|When using `register_only: True` will update the Satellite6 Host to your specified options. Defaults to `False`.|boolean|
|
||||
|provision_method|no|`build` or `image` deploy. Defaults to `build` |string
|
||||
|
||||
|
||||
## `sat6_hosts` Dictionary Fields - Virtual
|
||||
|
||||
|Field Name|Required|Description|Type|
|
||||
|---|:---:|---|:---:|
|
||||
|compute_profile|no|Name of the Satellite6 compute profile you want to deploy the host with. If not provided the default from the host group will be utilized.|string|
|
||||
|compute_resource|yes|Name of the Satellite6 compute resource you want to deploy the host on.|string|
|
||||
|
||||
## `sat6_hosts` Dictionary Fields - Physical
|
||||
|
||||
|Field Name|Required|Description|Type|
|
||||
|---|:---:|---|:---:|
|
||||
|mac|yes|MAC address of the physical host you want to deploy.|string|
|
||||
|
||||
## `sat6_hosts.parameters` Dictionary Fields
|
||||
|
||||
|Field Name|Required|Description|Type|
|
||||
|---|:---:|---|:---:|
|
||||
|name|yes|Name of the parameter to create|string|
|
||||
|value|yes|Value of the parameter to create|string|
|
||||
|
||||
|
||||
## Debugging
|
||||
To view full debugging output increase the verbosity to 1 (Verbose) in Ansible Tower, or a single `-v` in Ansible Core/Engine.
|
||||
|
||||
## Example Playbook
|
||||
|
||||
```yaml
|
||||
---
|
||||
- name: "ahuffman.sat6_create_hosts Example Playbook"
|
||||
hosts: "localhost"
|
||||
vars_files:
|
||||
- "vars/myvaultedsecrets.yml"
|
||||
tasks:
|
||||
- name: "Provision Satellite 6 Hosts"
|
||||
include_role:
|
||||
name: "ahuffman.sat6_create_hosts"
|
||||
vars:
|
||||
sat6_fqdn: "mysat6server.mydomain.com"
|
||||
sat6_user: "mysat6admin"
|
||||
#sat6_pass: "this is set in the vars/myvaultedsecrets.yml file"
|
||||
sat6_organization: "my organization"
|
||||
sat6_fail_on_existing: True
|
||||
#it's recommended to pass sat6_hosts as an extra_variable, but you could set
|
||||
#sat6_fail_on_existing: False to run the playbook in a more idempotent style if you wish to
|
||||
#keep track of all the sat6 hosts you create in source control
|
||||
sat6_hosts:
|
||||
#VM
|
||||
- name: "my-new-vm"
|
||||
host_group: "RHEL7-Virtual"
|
||||
location: "Raleigh"
|
||||
ipv4: "192.168.122.24"
|
||||
domain: "redhat.com"
|
||||
comment: "Web server to serve cool new website"
|
||||
compute_resource: "vsphere.vmware.com" #This is the name of your compute resource
|
||||
compute_profile: "3-Large"
|
||||
parameters:
|
||||
- name: "build_type"
|
||||
value: "httpd"
|
||||
#Bare-metal
|
||||
- name: "my-new-bare-metal"
|
||||
host_group: "RHEL7-Physical"
|
||||
location: "Raleigh"
|
||||
ipv4: "192.168.122.25"
|
||||
domain: "redhat.com"
|
||||
comment: "Database server"
|
||||
mac: "12:34:56:78:91:23"
|
||||
#Register Only(i.e. create only)
|
||||
- name: "host1"
|
||||
host_group: "RHEL7-Virtual"
|
||||
location: "Raleigh"
|
||||
ipv4: "192.168.122.26"
|
||||
domain: "redhat.com"
|
||||
comment: "Pre-registration host entry"
|
||||
register_only: True
|
||||
#Update an existing host (sorry for the lame joke)
|
||||
- name: "my-new-vm"
|
||||
host_group: "RHEL7-Virtual"
|
||||
location: "Armonk"
|
||||
ipv4: "192.168.122.24"
|
||||
comment: "Migrated Q3"
|
||||
domain: "ibm.com"
|
||||
parameters:
|
||||
- name: "build_type"
|
||||
value: "ihs"
|
||||
register_only: True #means don't try and provision
|
||||
force_host_update: True #update the host if it exists
|
||||
#Manage host builds (provisioning) on presently unmanaged existing host
|
||||
- name: "someoldserver"
|
||||
host_group: "RHEL7-Physical"
|
||||
mac: "32:34:56:78:91:23"
|
||||
domain: "redhat.com"
|
||||
location: "Raleigh"
|
||||
register_only: True
|
||||
force_host_update: True
|
||||
manage_host: True
|
||||
```
|
||||
|
||||
## License
|
||||
[MIT](LICENSE)
|
||||
|
||||
## Author Information
|
||||
[Andrew J. Huffman](https://github.com/ahuffman)
|
||||
@@ -1,29 +0,0 @@
|
||||
---
|
||||
sat6_hosts: []
|
||||
sat6_fqdn: ""
|
||||
sat6_user: ""
|
||||
sat6_pass: ""
|
||||
sat6_organization: ""
|
||||
sat6_fail_on_existing: False
|
||||
sat6_power_on_delay: "30"
|
||||
|
||||
#Example provision on compute resource:
|
||||
# sat6_hosts:
|
||||
# - name: "test-server"
|
||||
# location: "my location name"
|
||||
# domain: "mydomain.com" #optional if you want host group default
|
||||
# host_group: "RHEL7"
|
||||
# ipv4: "192.168.122.140" #optional if using ipam/dhcp on the host group subnet
|
||||
# comment: "A new server to test provisioning with." #optional
|
||||
# compute_profile: "2-Medium" #optional if you want to use the host group default
|
||||
# compute_resource: "my compute resource name"
|
||||
|
||||
#Example provision on baremetal:
|
||||
# sat6_hosts:
|
||||
# - name: "test-baremetal-server"
|
||||
# location: "my location name"
|
||||
# domain: "mydomain.com" #optional if you want host group default
|
||||
# host_group: "RHEL7"
|
||||
# ipv4: "192.168.122.140" #optional if using ipam/dhcp on the host group subnet
|
||||
# comment: "A new baremetal server to test provisioning with." #optional
|
||||
# mac: "01:21:AB:CD:EF:GH"
|
||||
@@ -1,2 +0,0 @@
|
||||
install_date: Mon Aug 17 14:48:39 2020
|
||||
version: 1.0.8
|
||||
@@ -1,77 +0,0 @@
|
||||
galaxy_info:
|
||||
author: "Andrew J. Huffman"
|
||||
description: "An Ansible role to create new virtual and bare-metal hosts in Satellite 6.x."
|
||||
company: "Red Hat"
|
||||
|
||||
# If the issue tracker for your role is not on github, uncomment the
|
||||
# next line and provide a value
|
||||
# issue_tracker_url: http://example.com/issue/tracker
|
||||
|
||||
# Some suggested licenses:
|
||||
# - BSD (default)
|
||||
# - MIT
|
||||
# - GPLv2
|
||||
# - GPLv3
|
||||
# - Apache
|
||||
# - CC-BY
|
||||
license: "MIT"
|
||||
|
||||
min_ansible_version: "2.5"
|
||||
|
||||
# If this a Container Enabled role, provide the minimum Ansible Container version.
|
||||
# min_ansible_container_version:
|
||||
|
||||
# Optionally specify the branch Galaxy will use when accessing the GitHub
|
||||
# repo for this role. During role install, if no tags are available,
|
||||
# Galaxy will use this branch. During import Galaxy will access files on
|
||||
# this branch. If Travis integration is configured, only notifications for this
|
||||
# branch will be accepted. Otherwise, in all cases, the repo's default branch
|
||||
# (usually master) will be used.
|
||||
#github_branch:
|
||||
|
||||
#
|
||||
# platforms is a list of platforms, and each platform has a name and a list of versions.
|
||||
#
|
||||
# platforms:
|
||||
# - name: Fedora
|
||||
# versions:
|
||||
# - all
|
||||
# - 25
|
||||
# - name: SomePlatform
|
||||
# versions:
|
||||
# - all
|
||||
# - 1.0
|
||||
# - 7
|
||||
# - 99.99
|
||||
platforms:
|
||||
- name: "EL"
|
||||
versions:
|
||||
- "all"
|
||||
- name: "Fedora"
|
||||
versions:
|
||||
- "all"
|
||||
- name: "Ubuntu"
|
||||
versions:
|
||||
- "all"
|
||||
- name: "Amazon"
|
||||
versions:
|
||||
- "all"
|
||||
- name: "Debian"
|
||||
versions:
|
||||
- "all"
|
||||
|
||||
galaxy_tags:
|
||||
- "system"
|
||||
- "satellite6"
|
||||
- "provisioning"
|
||||
- "satellite"
|
||||
# List tags for your role here, one per line. A tag is a keyword that describes
|
||||
# and categorizes the role. Users find roles by searching for tags. Be sure to
|
||||
# remove the '[]' above, if you add tags to this list.
|
||||
#
|
||||
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
|
||||
# Maximum 20 tags per role.
|
||||
|
||||
dependencies: []
|
||||
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
|
||||
# if you add dependencies to this list.
|
||||
@@ -1,540 +0,0 @@
|
||||
---
|
||||
- name: "Clear facts"
|
||||
set_fact:
|
||||
host_id: ""
|
||||
location_id: ""
|
||||
host_grp_id: ""
|
||||
compute_resource_id: ""
|
||||
compute_profile_id: ""
|
||||
host_fqdn: ""
|
||||
host_exists: ""
|
||||
partition_table_id: ""
|
||||
subnet_id: ""
|
||||
domain_id: ""
|
||||
failed_host: []
|
||||
created_host: []
|
||||
updated_host: []
|
||||
|
||||
- name: "Obtain Satellite6 Host Group ID"
|
||||
block:
|
||||
- name: "Obtain Satellite6 Host Group ID"
|
||||
uri:
|
||||
body: "{\"search\": 'title=\"{{ host.host_group }}\"'}"
|
||||
vars:
|
||||
sat6_url_path: "api/v2/hostgroups"
|
||||
register: "host_grp_qry"
|
||||
|
||||
- debug:
|
||||
var: "host_grp_qry.json.results[0]"
|
||||
verbosity: "1"
|
||||
|
||||
- name: "Set Satellite6 Host Group ID"
|
||||
set_fact:
|
||||
host_grp_id: "{{ host_grp_qry.json.results[0].id }}"
|
||||
when: "host_grp_qry.json.results[0].title == host.host_group"
|
||||
|
||||
- debug:
|
||||
var: "host_grp_id"
|
||||
verbosity: "1"
|
||||
tags:
|
||||
- "host_group_id"
|
||||
|
||||
- name: "Check if Satellite6 host exists"
|
||||
block:
|
||||
- name: "Set Satellite6 host fqdn | Domain Default from Host Group"
|
||||
set_fact:
|
||||
host_fqdn: "{{ host.name }}.{{ host_grp_qry.json.results[0].domain_name }}"
|
||||
when:
|
||||
- "not host.domain | default('')"
|
||||
- "host_grp_qry.json.results[0].domain_name"
|
||||
|
||||
- name: "Set Satellite6 host fqdn | Domain Specified"
|
||||
set_fact:
|
||||
host_fqdn: "{{ host.name }}.{{ host.domain }}"
|
||||
when: "host.domain | default('')"
|
||||
|
||||
- debug:
|
||||
var: "host_fqdn"
|
||||
verbosity: "1"
|
||||
|
||||
- name: "Check if Satellite6 host {{ host_fqdn }} exists"
|
||||
uri:
|
||||
body: "{\"search\": 'name=\"{{ host_fqdn }}\"'}"
|
||||
vars:
|
||||
sat6_url_path: "api/v2/hosts"
|
||||
register: "host_qry"
|
||||
|
||||
- debug:
|
||||
var: "host_qry.json.results[0]"
|
||||
verbosity: "1"
|
||||
|
||||
- name: "Set Satellite6 Host {{ host_fqdn }} Exists | True"
|
||||
set_fact:
|
||||
host_exists: True
|
||||
when:
|
||||
- "host_qry.json.results | length > 0"
|
||||
- "host_qry.json.results[0].name == host_fqdn"
|
||||
|
||||
- name: "Set Satellite6 Host {{ host_fqdn }} Exists | False"
|
||||
set_fact:
|
||||
host_exists: False
|
||||
when:
|
||||
- "host_qry.json.results | length < 1"
|
||||
|
||||
- name: "Set Satellite6 Host id"
|
||||
set_fact:
|
||||
host_id: "{{ host_qry.json.results[0].id }}"
|
||||
when:
|
||||
- "not sat6_fail_on_existing"
|
||||
- "host.force_host_update | default(False)"
|
||||
- "host.register_only | default(False)"
|
||||
- "host_exists"
|
||||
|
||||
- debug:
|
||||
var: "host_exists"
|
||||
verbosity: "1"
|
||||
|
||||
- debug:
|
||||
var: "host_id"
|
||||
verbosity: "1"
|
||||
when:
|
||||
- "not sat6_fail_on_existing"
|
||||
- "host.force_host_update | default(False)"
|
||||
- "host.register_only | default(False)"
|
||||
- "host_exists"
|
||||
tags:
|
||||
- "host_exists_check"
|
||||
|
||||
- name: "Obtain Satellite6 Domain ID"
|
||||
block:
|
||||
- name: "Obtain Satellite6 Domain ID"
|
||||
uri:
|
||||
body: "{\"search\": 'name=\"{{ host.domain }}\"'}"
|
||||
vars:
|
||||
sat6_url_path: "api/v2/domains"
|
||||
register: "domain_qry"
|
||||
|
||||
- debug:
|
||||
var: "domain_qry.json.results[0]"
|
||||
verbosity: "1"
|
||||
|
||||
- name: "Set Satellite6 Domain ID"
|
||||
set_fact:
|
||||
domain_id: "{{ domain_qry.json.results[0].id }}"
|
||||
when: "domain_qry.json.results[0].name == host.domain"
|
||||
|
||||
- debug:
|
||||
var: "domain_id"
|
||||
verbosity: "1"
|
||||
when: (not host_exists and host.domain is defined) or
|
||||
(host_exists and
|
||||
host.force_host_update | default(False) and
|
||||
host.domain is defined and
|
||||
host.register_only | default(False) and
|
||||
not sat6_fail_on_existing)
|
||||
|
||||
- name: "Obtain Satellite6 Location ID"
|
||||
block:
|
||||
- name: "Obtain Satellite6 Location ID"
|
||||
uri:
|
||||
body: "{\"search\": 'name=\"{{ host.location }}\"'}"
|
||||
vars:
|
||||
sat6_url_path: "api/v2/locations"
|
||||
register: "loc_qry"
|
||||
|
||||
- debug:
|
||||
var: "loc_qry.json.results[0]"
|
||||
verbosity: "1"
|
||||
|
||||
- name: "Set Satellite6 Location ID"
|
||||
set_fact:
|
||||
location_id: "{{ loc_qry.json.results[0].id }}"
|
||||
when: "loc_qry.json.results[0].name == host.location"
|
||||
|
||||
- debug:
|
||||
var: "location_id"
|
||||
verbosity: "1"
|
||||
when: (not host_exists) or
|
||||
(host_exists and host.force_host_update | default(False) and host.register_only | default(False) and not sat6_fail_on_existing)
|
||||
tags:
|
||||
- "location_id"
|
||||
|
||||
- name: "Obtain Satellite6 Compute Resource ID | Specified"
|
||||
block:
|
||||
- name: "Obtain Satellite6 Compute Resource ID"
|
||||
uri:
|
||||
body: "{\"search\": 'name=\"{{ host.compute_resource }}\"'}"
|
||||
vars:
|
||||
sat6_url_path: "api/v2/compute_resources"
|
||||
register: "compute_resource_qry"
|
||||
|
||||
- debug:
|
||||
var: "compute_resource_qry.json.results[0]"
|
||||
verbosity: "1"
|
||||
|
||||
- name: Set Satellite6 Compute Resource ID
|
||||
set_fact:
|
||||
compute_resource_id: "{{ compute_resource_qry.json.results[0].id }}"
|
||||
when: "compute_resource_qry.json.results[0].name == host.compute_resource"
|
||||
|
||||
- debug:
|
||||
var: "compute_resource_id"
|
||||
verbosity: "1"
|
||||
when: (not host_exists and host.compute_resource is defined and host.mac is undefined) or
|
||||
(host_exists and
|
||||
host.force_host_update | default(False) and
|
||||
host.compute_resource is defined and
|
||||
host.mac is undefined and
|
||||
host.register_only | default(False) and
|
||||
not sat6_fail_on_existing)
|
||||
tags:
|
||||
- "compute_resource_id"
|
||||
|
||||
- name: "Obtain Satellite6 Compute Profile ID | Specified"
|
||||
block:
|
||||
- name: "Obtain Satellite6 Compute Profile ID"
|
||||
uri:
|
||||
body: "{\"search\": 'name=\"{{ host.compute_profile | truncate(20, True, '') }}\"'}"
|
||||
vars:
|
||||
sat6_url_path: "api/v2/compute_profiles"
|
||||
register: "compute_profile_qry"
|
||||
|
||||
- debug:
|
||||
var: "compute_profile_qry.json.results[0]"
|
||||
verbosity: "1"
|
||||
|
||||
- name: "Set Satellite6 Compute Profile ID | Specified"
|
||||
set_fact:
|
||||
compute_profile_id: "{{ compute_profile_qry.json.results[0].id }}"
|
||||
when: "compute_profile_qry.json.results[0].name == host.compute_profile"
|
||||
|
||||
- debug:
|
||||
var: "compute_profile_id"
|
||||
verbosity: "1"
|
||||
when: (not host_exists and host.compute_profile is defined) or
|
||||
(host_exists and host.force_host_update | default(False) and host.register_only | default(False) and host.compute_profile is defined)
|
||||
tags:
|
||||
- "compute_profile_id"
|
||||
|
||||
- name: "Obtain Satellite6 Compute Profile ID | Default from Host Group"
|
||||
block:
|
||||
- name: "Obtain Compute Profile"
|
||||
uri:
|
||||
body: "{\"search\": 'name=\"{{ host_grp_qry.json.results[0].compute_profile_name }}\"', \"per_page\": \"1000\"}"
|
||||
vars:
|
||||
sat6_url_path: "api/v2/compute_profiles"
|
||||
register: "inherit_compute_profile_qry"
|
||||
|
||||
- debug:
|
||||
var: "inherit_compute_profile_qry.json.results[0]"
|
||||
verbosity: "1"
|
||||
|
||||
- name: "Set Compute Profile ID"
|
||||
set_fact:
|
||||
compute_profile_id: "{{ inherit_compute_profile_qry.json.results[0].id }}"
|
||||
when:
|
||||
- "not host_exists"
|
||||
- "host.compute_profile is undefined"
|
||||
- "host.mac is undefined"
|
||||
- "not host.register_only | default(False)"
|
||||
tags:
|
||||
- "compute_profile_id"
|
||||
|
||||
- name: "Obtain Satellite6 Subnet ID"
|
||||
block:
|
||||
- name: "Obtain Satellite6 Subnet ID"
|
||||
uri:
|
||||
body: "{\"search\": 'name=\"{{ host.subnet }}\"'}"
|
||||
vars:
|
||||
sat6_url_path: "api/v2/subnets"
|
||||
register: "subnet_qry"
|
||||
|
||||
- debug:
|
||||
var: "subnet_qry.json.results[0]"
|
||||
verbosity: "1"
|
||||
|
||||
- name: "Set Satellite6 Subnet ID"
|
||||
set_fact:
|
||||
subnet_id: "{{ subnet_qry.json.results[0].id }}"
|
||||
when: "subnet_qry.json.results[0].name == host.subnet"
|
||||
|
||||
- debug:
|
||||
var: "subnet_id"
|
||||
verbosity: "1"
|
||||
when: (not host_exists and host.subnet is defined) or
|
||||
(host_exists and
|
||||
host.force_host_update | default(False) and
|
||||
host.register_only | default(False) and
|
||||
host.subnet is defined and
|
||||
not sat6_fail_on_existing)
|
||||
tags:
|
||||
- "subnet_id"
|
||||
|
||||
- name: "Obtain Satellite6 partition table ID"
|
||||
block:
|
||||
- name: "Obtain Satellite6 partition table ID"
|
||||
uri:
|
||||
body: "{\"search\": 'name=\"{{ host.partition_table }}\"'}"
|
||||
vars:
|
||||
sat6_url_path: "api/v2/ptables"
|
||||
register: "partition_table_qry"
|
||||
|
||||
- debug:
|
||||
var: "partition_table_qry.json.results[0]"
|
||||
verbosity: "1"
|
||||
|
||||
- name: Set Satellite6 partition table ID
|
||||
set_fact:
|
||||
partition_table_id: "{{ partition_table_qry.json.results[0].id }}"
|
||||
when: "partition_table_qry.json.results[0].name == host.partition_table"
|
||||
|
||||
- debug:
|
||||
var: "partition_table_id"
|
||||
verbosity: "1"
|
||||
when: (not host_exists and host.partition_table is defined) or
|
||||
(host_exists and
|
||||
host.force_host_update | default(False) and
|
||||
host.register_only | default(False) and
|
||||
host.partition_table is defined and
|
||||
not sat6_fail_on_existing)
|
||||
tags:
|
||||
- "partition_table_id"
|
||||
|
||||
# Virtual Host Creation and Updating
|
||||
- name: "Create new Satellite 6 host"
|
||||
block:
|
||||
- name: "Create new Satellite 6 host {{ host_fqdn }} | Virtual"
|
||||
block:
|
||||
- name: "Create new Satellite 6 host {{ host_fqdn }} | Virtual"
|
||||
uri:
|
||||
method: "POST"
|
||||
body: "{{ lookup('template', 'new_host_virtual.json.j2') }}"
|
||||
status_code: "201"
|
||||
timeout: 180
|
||||
vars:
|
||||
sat6_url_path: "api/v2/hosts"
|
||||
register: "create_host_results"
|
||||
|
||||
- debug:
|
||||
var: "create_host_results"
|
||||
verbosity: "1"
|
||||
|
||||
- name: "Wait for host creation to complete"
|
||||
pause:
|
||||
seconds: "{{ sat6_power_on_delay | default('30') }}"
|
||||
|
||||
# - name: "Power on Satellite6 host {{ host_fqdn }}"
|
||||
# uri:
|
||||
# body: "{\"power_action\": \"start\"}"
|
||||
# method: "PUT"
|
||||
# vars:
|
||||
# sat6_url_path: "api/v2/hosts/{{ create_host_results.json.id }}/power"
|
||||
# register: "power_result"
|
||||
# failed_when:
|
||||
# - "'[Cannot run VM because the VM is in Up status.]' not in power_result.json.error.message"
|
||||
|
||||
# - debug:
|
||||
# var: "power_result"
|
||||
# verbosity: "1"
|
||||
|
||||
- set_fact:
|
||||
created_host: ["{{ host_fqdn }}"]
|
||||
# when:
|
||||
# - "create_host_results.status == 201"
|
||||
# - "power_result.status == 200"
|
||||
when:
|
||||
- "not host_exists"
|
||||
- "compute_profile_id is defined"
|
||||
- "compute_resource_id is defined"
|
||||
- "domain_id is defined"
|
||||
- "host.mac is undefined"
|
||||
- "not host.register_only | default(False)"
|
||||
|
||||
- name: "Create new Satellite 6 host {{ host_fqdn }} | Virtual (register_only)"
|
||||
block:
|
||||
- name: "Create new Satellite 6 host {{ host_fqdn }} | Virtual (register_only)"
|
||||
uri:
|
||||
method: "POST"
|
||||
body: "{{ lookup('template', 'new_host_virtual_register_only.json.j2') }}"
|
||||
status_code: "201"
|
||||
vars:
|
||||
sat6_url_path: "api/v2/hosts"
|
||||
register: "create_host_results"
|
||||
|
||||
- debug:
|
||||
var: "create_host_results"
|
||||
verbosity: "1"
|
||||
|
||||
- set_fact:
|
||||
created_host: ["{{ host_fqdn }}"]
|
||||
when:
|
||||
- "create_host_results.status == 201"
|
||||
when:
|
||||
- "not host_exists"
|
||||
- "host.mac is undefined"
|
||||
- "domain_id is defined"
|
||||
- "host.register_only | default(False)"
|
||||
|
||||
- name: "Update existing Satellite 6 host {{ host_fqdn }} | Virtual"
|
||||
block:
|
||||
- name: "Update existing Satellite 6 host {{ host_fqdn }} | Virtual"
|
||||
uri:
|
||||
method: "PUT"
|
||||
body: "{{ lookup('template', 'new_host_virtual_register_only.json.j2') }}"
|
||||
vars:
|
||||
sat6_url_path: "api/v2/hosts/{{ host_id }}"
|
||||
register: "update_host_results"
|
||||
|
||||
- debug:
|
||||
var: "update_host_results"
|
||||
verbosity: "1"
|
||||
|
||||
- set_fact:
|
||||
updated_host: ["{{ host_fqdn }}"]
|
||||
when:
|
||||
- "update_host_results.status == 200"
|
||||
when:
|
||||
- "host_exists"
|
||||
- "host.force_host_update | default(False)"
|
||||
- "host.register_only | default(False)"
|
||||
- "host.mac is undefined"
|
||||
- "domain_id is defined"
|
||||
- "not sat6_fail_on_existing"
|
||||
|
||||
# Bare-metal Host Creation and Updating
|
||||
- name: "Create new Satellite 6 host {{ host_fqdn }} | Physical"
|
||||
block:
|
||||
- name: "Create new Satellite 6 host {{ host_fqdn }} | Physical"
|
||||
uri:
|
||||
method: "POST"
|
||||
body: "{{ lookup('template', 'new_host_physical.json.j2') }}"
|
||||
status_code: "201"
|
||||
vars:
|
||||
sat6_url_path: "api/v2/hosts"
|
||||
register: "create_host_results"
|
||||
|
||||
- debug:
|
||||
var: "create_host_results"
|
||||
verbosity: "1"
|
||||
|
||||
- set_fact:
|
||||
created_host: ["{{ host_fqdn }}"]
|
||||
when: "create_host_results.status == 201"
|
||||
when:
|
||||
- "not host_exists"
|
||||
- "host.mac is defined"
|
||||
- "domain_id is defined"
|
||||
- "host.compute_profile is undefined"
|
||||
- "host.compute_resource is undefined"
|
||||
- "not host.register_only | default(False)"
|
||||
|
||||
- name: "Create new Satellite 6 host {{ host_fqdn }} | Physical (register only)"
|
||||
block:
|
||||
- name: "Create new Satellite 6 host {{ host_fqdn }} | Physical (register only)"
|
||||
uri:
|
||||
method: "POST"
|
||||
body: "{{ lookup('template', 'new_host_physical_register_only.json.j2') }}"
|
||||
status_code: "201"
|
||||
vars:
|
||||
sat6_url_path: "api/v2/hosts"
|
||||
register: "create_host_results"
|
||||
|
||||
- debug:
|
||||
var: "create_host_results"
|
||||
verbosity: "1"
|
||||
|
||||
- set_fact:
|
||||
created_host: ["{{ host_fqdn }}"]
|
||||
when: "create_host_results.status == 201"
|
||||
when:
|
||||
- "not host_exists"
|
||||
- "host.mac is defined"
|
||||
- "domain_id is defined"
|
||||
- "host.compute_profile is undefined"
|
||||
- "host.compute_resource is undefined"
|
||||
- "host.register_only | default(False)"
|
||||
|
||||
- name: "Update existing Satellite 6 host {{ host_fqdn }} | Physical"
|
||||
block:
|
||||
- name: "Update existing Satellite 6 host {{ host_fqdn }} | Physical"
|
||||
uri:
|
||||
method: "PUT"
|
||||
body: "{{ lookup('template', 'new_host_physical_register_only.json.j2') }}"
|
||||
vars:
|
||||
sat6_url_path: "api/v2/hosts/{{ host_id }}"
|
||||
register: "update_host_results"
|
||||
|
||||
- debug:
|
||||
var: "update_host_results"
|
||||
verbosity: "1"
|
||||
|
||||
- set_fact:
|
||||
updated_host: ["{{ host_fqdn }}"]
|
||||
when: "update_host_results.status == 200"
|
||||
when:
|
||||
- "host_exists"
|
||||
- "host.force_host_update | default(False)"
|
||||
- "host.register_only | default(False)"
|
||||
- "host.mac is defined"
|
||||
- "domain_id is defined"
|
||||
- "host.compute_profile is undefined"
|
||||
- "host.compute_resource is undefined"
|
||||
- "not sat6_fail_on_existing"
|
||||
|
||||
- name: "Build list of Created Hosts"
|
||||
set_fact:
|
||||
created_hosts: "{{ created_hosts | union(created_host) }}"
|
||||
when: "created_host | length > 0"
|
||||
|
||||
- name: "Build list of Updated Hosts"
|
||||
set_fact:
|
||||
updated_hosts: "{{ updated_hosts | union(updated_host) }}"
|
||||
when: "updated_host | length > 0"
|
||||
when: (not host_exists) or
|
||||
(host_exists and host.force_host_update | default(False) and host.register_only | default(False) and not sat6_fail_on_existing)
|
||||
|
||||
- name: "Handle existing Satellite6 hosts | Fail on existing"
|
||||
block:
|
||||
- debug:
|
||||
msg: "{{ host_fqdn }} already exists. Not attempting to create."
|
||||
|
||||
- name: "Failed host"
|
||||
set_fact:
|
||||
failed_host: ["{{ host_fqdn }}"]
|
||||
|
||||
- name: "Build list of failed hosts | fail"
|
||||
set_fact:
|
||||
failed_hosts: "{{ failed_hosts | union(failed_host) }}"
|
||||
fail_playbook: True
|
||||
when: "sat6_fail_on_existing"
|
||||
when:
|
||||
- "host_exists"
|
||||
- "sat6_fail_on_existing"
|
||||
- "not host.force_host_update | default(False)"
|
||||
|
||||
- name: "Handle existing Satellite6 hosts | No fail"
|
||||
block:
|
||||
- debug:
|
||||
msg: "{{ host_fqdn }} already exists. Not attempting to create."
|
||||
when: "not host.force_host_update"
|
||||
|
||||
- name: "Failed host"
|
||||
set_fact:
|
||||
failed_host: ["{{ host_fqdn }}"]
|
||||
when: "not host.force_host_update"
|
||||
|
||||
- name: "Build list of failed hosts | no fail"
|
||||
set_fact:
|
||||
failed_hosts: "{{ failed_hosts | union(failed_host) }}"
|
||||
when: "not host.force_host_update"
|
||||
|
||||
- debug:
|
||||
msg:
|
||||
- "{{ host_fqdn }} already exists. Not attempting to create."
|
||||
- "Updated {{ host_fqdn }}"
|
||||
when:
|
||||
- "host.force_host_update | default(False)"
|
||||
- "host.register_only | default(False)"
|
||||
when:
|
||||
- "host_exists"
|
||||
- "not sat6_fail_on_existing"
|
||||
@@ -1,114 +0,0 @@
|
||||
---
|
||||
- name: "Satellite6 Create Hosts"
|
||||
block:
|
||||
- name: "Ensure we have the Satellite Server's CA for validating authentication"
|
||||
stat:
|
||||
path: "/etc/pki/ca-trust/source/anchors/katello-server-ca.crt"
|
||||
register: "ca_cert"
|
||||
|
||||
- name: "Obtain Satellite Server's CA for validating authentication"
|
||||
block:
|
||||
- name: "Download CA Certificate"
|
||||
get_url:
|
||||
url: "http://{{ sat6_fqdn }}/pub/katello-server-ca.crt"
|
||||
dest: "/etc/pki/ca-trust/source/anchors/katello-server-ca.crt"
|
||||
|
||||
- name: "Update CA trust"
|
||||
command: "update-ca-trust"
|
||||
when: "not ca_cert.stat.exists"
|
||||
become: True
|
||||
|
||||
- name: "Obtain Satellite6 Organization ID"
|
||||
block:
|
||||
- name: "Obtain Satellite6 Organization ID"
|
||||
uri:
|
||||
body: "{\"search\": 'name=\"{{ sat6_organization }}\"'}"
|
||||
vars:
|
||||
sat6_url_path: "api/v2/organizations"
|
||||
register: "org_qry"
|
||||
|
||||
- debug:
|
||||
var: "org_qry.json.results[0]"
|
||||
verbosity: "1"
|
||||
|
||||
- name: "Set Satellite6 Organization ID"
|
||||
set_fact:
|
||||
organization_id: "{{ org_qry.json.results[0].id }}"
|
||||
when: "org_qry.json.results[0].name == sat6_organization"
|
||||
|
||||
- debug:
|
||||
var: "organization_id"
|
||||
verbosity: "1"
|
||||
tags:
|
||||
- "organization_id"
|
||||
|
||||
- name: "Initialize lists"
|
||||
set_fact:
|
||||
failed_hosts: []
|
||||
created_hosts: []
|
||||
updated_hosts: []
|
||||
|
||||
- name: "Create new Satellite 6 Hosts"
|
||||
include_tasks: "create_host.yml"
|
||||
with_items: "{{ sat6_hosts }}"
|
||||
loop_control:
|
||||
loop_var: "host"
|
||||
label: "{{ host.name }}"
|
||||
when: "sat6_hosts | length > 0"
|
||||
|
||||
# Output summary/failure messages based on several conditions
|
||||
- debug:
|
||||
msg: "No hosts were created."
|
||||
when: "created_hosts | length < 1"
|
||||
|
||||
- name: "Playbook fail"
|
||||
fail:
|
||||
msg:
|
||||
- "List of hosts to provision missing."
|
||||
- "Variable sat6_hosts list empty."
|
||||
when: "sat6_hosts | length < 1"
|
||||
|
||||
- debug:
|
||||
msg:
|
||||
- "Host(s) created successfully:"
|
||||
- "{{ created_hosts }}"
|
||||
when: "created_hosts | length > 0"
|
||||
|
||||
# when we want to fail the playbook on existing sat6 hosts
|
||||
- name: "Playbook fail when host exists"
|
||||
fail:
|
||||
msg:
|
||||
- "Host(s) already exist in Satellite6:"
|
||||
- "{{ failed_hosts }}"
|
||||
when:
|
||||
- "fail_playbook | default(False)"
|
||||
- "sat6_fail_on_existing"
|
||||
|
||||
# when we don't want to fail the playbook on existing sat6 hosts
|
||||
## Handles where we are using host.force_host_update: False
|
||||
- debug:
|
||||
msg:
|
||||
- "Host(s) already exist in Satellite6:"
|
||||
- "{{ failed_hosts }}"
|
||||
when:
|
||||
- "not sat6_fail_on_existing"
|
||||
- "failed_hosts | length > 0"
|
||||
|
||||
## Handles where we are using host.force_host_update: True
|
||||
- debug:
|
||||
msg:
|
||||
- "Host(s) already existed and were updated in Satellite6:"
|
||||
- "{{ updated_hosts }}"
|
||||
when:
|
||||
- "not sat6_fail_on_existing"
|
||||
- "updated_hosts | length > 0"
|
||||
# set uri module defaults to avoid repetitive params
|
||||
module_defaults:
|
||||
uri:
|
||||
user: "{{ sat6_user }}"
|
||||
password: "{{ sat6_pass }}"
|
||||
force_basic_auth: True
|
||||
url: "https://{{ sat6_fqdn }}/{{ sat6_url_path | default('') }}"
|
||||
method: "GET"
|
||||
status_code: "200"
|
||||
body_format: "json"
|
||||
@@ -1,36 +0,0 @@
|
||||
{"host": {
|
||||
"name": "{{ host_fqdn }}",
|
||||
"organization_id": "{{ organization_id }}",
|
||||
"location_id": "{{ location_id }}",
|
||||
{% if host.ipv4 is defined %}
|
||||
"ip": "{{ host.ipv4 }}",
|
||||
{% endif %}
|
||||
"mac": "{{ host.mac }}",
|
||||
{% if domain_id != "" %}
|
||||
"domain_id": "{{ domain_id }}",
|
||||
{% endif %}
|
||||
{% if subnet_id != "" %}
|
||||
"subnet_id": "{{ subnet_id }}",
|
||||
{% endif %}
|
||||
{% if partition_table_id != "" %}
|
||||
"ptable_id": "{{ partition_table_id }}",
|
||||
{% endif %}
|
||||
"hostgroup_id": "{{ host_grp_id }}",
|
||||
{% if host.parameters is defined %}
|
||||
{% if host.parameters | length > 0 %}
|
||||
"host_parameters_attributes": [
|
||||
{% for param in host.parameters %}
|
||||
{
|
||||
"name": "{{ param.name }}", "value": "{{ param.value }}"
|
||||
}{% if not loop.last %},{% endif %}
|
||||
{% endfor %}
|
||||
],
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
"comment": "{{ host.comment | default('') }}",
|
||||
"build": "true",
|
||||
"provision_method": "build",
|
||||
"managed": "true",
|
||||
"enabled": "true"
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
{"host": {
|
||||
"name": "{{ host_fqdn }}",
|
||||
"organization_id": "{{ organization_id }}",
|
||||
"location_id": "{{ location_id }}",
|
||||
{% if host.ipv4 is defined %}
|
||||
"ip": "{{ host.ipv4 }}",
|
||||
{% endif %}
|
||||
"mac": "{{ host.mac }}",
|
||||
{% if domain_id != "" %}
|
||||
"domain_id": "{{ domain_id }}",
|
||||
{% endif %}
|
||||
{% if subnet_id != "" %}
|
||||
"subnet_id": "{{ subnet_id }}",
|
||||
{% endif %}
|
||||
"hostgroup_id": "{{ host_grp_id }}",
|
||||
{% if host.parameters is defined %}
|
||||
{% if host.parameters | length > 0 %}
|
||||
"host_parameters_attributes": [
|
||||
{% for param in host.parameters %}
|
||||
{
|
||||
"name": "{{ param.name }}", "value": "{{ param.value }}"
|
||||
}{% if not loop.last %},{% endif %}
|
||||
{% endfor %}
|
||||
],
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
"comment": "{{ host.comment | default('') }}",
|
||||
"build": "false",
|
||||
{% if host.manage_host | default(False) %}
|
||||
"managed": "true",
|
||||
{% else %}
|
||||
"managed": "false",
|
||||
{% endif %}
|
||||
"enabled": "true"
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
{"host": {
|
||||
"name": "{{ host_fqdn }}",
|
||||
"organization_id": "{{ organization_id }}",
|
||||
"location_id": "{{ location_id }}",
|
||||
{% if host.ipv4 is defined %}
|
||||
"ip": "{{ host.ipv4 }}",
|
||||
{% endif %}
|
||||
{% if domain_id != "" %}
|
||||
"domain_id": "{{ domain_id }}",
|
||||
{% endif %}
|
||||
{% if subnet_id != "" %}
|
||||
"subnet_id": "{{ subnet_id }}",
|
||||
{% endif %}
|
||||
{% if partition_table_id != "" %}
|
||||
"ptable_id": "{{ partition_table_id }}",
|
||||
{% endif %}
|
||||
"hostgroup_id": "{{ host_grp_id }}",
|
||||
{% if host.parameters is defined %}
|
||||
{% if host.parameters | length > 0 %}
|
||||
"host_parameters_attributes": [
|
||||
{% for param in host.parameters %}
|
||||
{
|
||||
"name": "{{ param.name }}", "value": "{{ param.value }}"
|
||||
}{% if not loop.last %},{% endif %}
|
||||
{% endfor %}
|
||||
],
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
"comment": "{{ host.comment | default('') }}",
|
||||
"compute_resource_id": "{{ compute_resource_id }}",
|
||||
"compute_profile_id": "{{ compute_profile_id }}",
|
||||
"build": "true",
|
||||
"provision_method": "{{ host.provision_method | default('build') }}",
|
||||
"managed": "true",
|
||||
"enabled": "true",
|
||||
"compute_attributes": {
|
||||
"start": "1"
|
||||
},
|
||||
"interfaces_attributes": [{
|
||||
"ip": "{{ host.ipv4 }}",
|
||||
"identifier": "eth0",
|
||||
"type": "interface",
|
||||
"managed": "true",
|
||||
"domain_id": "{{ domain_id }}",
|
||||
"subnet_id": "{{ subnet_id }}"
|
||||
}]
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
{"host": {
|
||||
"name": "{{ host_fqdn }}",
|
||||
"organization_id": "{{ organization_id }}",
|
||||
"location_id": "{{ location_id }}",
|
||||
{% if host.ipv4 is defined %}
|
||||
"ip": "{{ host.ipv4 }}",
|
||||
{% endif %}
|
||||
{% if domain_id != "" %}
|
||||
"domain_id": "{{ domain_id }}",
|
||||
{% endif %}
|
||||
{% if subnet_id != "" %}
|
||||
"subnet_id": "{{ subnet_id }}",
|
||||
{% endif %}
|
||||
"hostgroup_id": "{{ host_grp_id }}",
|
||||
{% if host.parameters is defined %}
|
||||
{% if host.parameters | length > 0 %}
|
||||
"host_parameters_attributes": [
|
||||
{% for param in host.parameters %}
|
||||
{
|
||||
"name": "{{ param.name }}", "value": "{{ param.value }}"
|
||||
}{% if not loop.last %},{% endif %}
|
||||
{% endfor %}
|
||||
],
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
"comment": "{{ host.comment | default('') }}",
|
||||
{% if compute_resource_id is defined %}
|
||||
"compute_resource_id": "{{ compute_resource_id }}",
|
||||
{% endif %}
|
||||
{% if compute_profile_id is defined %}
|
||||
"compute_profile_id": "{{ compute_profile_id }}",
|
||||
{% endif %}
|
||||
"build": "false",
|
||||
{% if host.manage_host | default(False) %}
|
||||
"managed": "true",
|
||||
{% else %}
|
||||
"managed": "false",
|
||||
{% endif %}
|
||||
"enabled": "true"
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
---
|
||||
Reference in New Issue
Block a user