ahuffman / sat6-create-hosts Goto Github PK
View Code? Open in Web Editor NEWAn Ansible role to create new virtual and bare-metal hosts in Satellite 6.x. v2 of Satellite6 API is required.
License: MIT License
An Ansible role to create new virtual and bare-metal hosts in Satellite 6.x. v2 of Satellite6 API is required.
License: MIT License
Hello!
I got following error on Satellite 6.5.3 when I want to create a new host:
TASK [ahuffman.sat6_create_hosts : Set Satellite6 Compute Profile ID | Specified] ********************************************************************************************************************************************************************************************* task path: /ansible-galaxy-roles/ahuffman.sat6_create_hosts/tasks/create_host.yml:206 fatal: [localhost]: FAILED! => { "msg": "The conditional check 'compute_profile_qry.json.results[0].name == host.compute_profile' failed. The error was: error while evaluating conditional (compute_profile_qry.json.results[0].name == host.compute_profile): list object has no element 0\n\nThe error appears to be in '/ansible-galaxy-roles/ahuffman.sat6_create_hosts/tasks/create_host.yml': line 206, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - name: \"Set Satellite6 Compute Profile ID | Specified\"\n ^ here\n" }
If I run the playbook in -vvv mode, I will get the following output for this tasks:
TASK [ahuffman.sat6_create_hosts : Obtain Satellite6 Compute Profile ID] ****************************************************************************************************************************************************************************************************** task path: /ansible-galaxy-roles/ahuffman.sat6_create_hosts/tasks/create_host.yml:195 <127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: notshownhere <127.0.0.1> EXEC /bin/sh -c 'echo ~ansible && sleep 0' <127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "
echo /tmp/ansible-tmp " && echo ansible-tmp="
echo /tmp/ansible-tmp `" ) && sleep 0'
Using module file /usr/lib/python2.7/site-packages/ansible/modules/net_tools/basics/uri.py
<127.0.0.1> PUT /tmp/ansible-local-18492gHDhB3/tmpOWJrDL TO /tmp/ansible-tmp/AnsiballZ_uri.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /tmp/ansible-tmp/ /tmp/ansible-tmp/AnsiballZ_uri.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'sudo -H -S -n -u root /bin/sh -c '"'"'echo BECOME-SUCCESS- ; /usr/bin/python2 /tmp/ansible-tmp/AnsiballZ_uri.py'"'"' && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /tmp/ansible-tmp/ > /dev/null 2>&1 && sleep 0'
ok: [localhost] => {
"apipie_checksum": "",
"cache_control": "max-age=0, private, must-revalidate",
"changed": false,
"connection": "close",
"content_type": "application/json; charset=utf-8",
"cookies": {
"_session_id": ""
},
"cookies_string": "_session_id=",
"date": "Wed, 24 Jun 2020 12:29:25 GMT",
"elapsed": 0,
"etag": "W/""",
"foreman_api_version": "2",
"foreman_version": "1.20.1.36",
"invocation": {
"module_args": {
"attributes": null,
"backup": null,
"body": {
"search": "name="ABCD-EFG-Hij+KlmnOpq""
},
"body_format": "json",
"client_cert": null,
"client_key": null,
"content": null,
"creates": null,
"delimiter": null,
"dest": null,
"directory_mode": null,
"follow": false,
"follow_redirects": "safe",
"force": false,
"force_basic_auth": true,
"group": null,
"headers": {
"Content-Type": "application/json"
},
"http_agent": "ansible-httpget",
"method": "GET",
"mode": null,
"owner": null,
"password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"regexp": null,
"remote_src": null,
"removes": null,
"return_content": false,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"src": null,
"status_code": [
"200"
],
"timeout": 30,
"unix_socket": null,
"unsafe_writes": null,
"url": "https://satellite.example.com/api/v2/compute_profiles",
"url_password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"url_username": "notshownhere",
"use_proxy": true,
"user": "notshownhere",
"validate_certs": true
}
},
"json": {
"page": 1,
"per_page": 20,
"results": [],
"search": "name="ABCD-EFG-Hij+KlmnOpq"",
"sort": {
"by": null,
"order": null
},
"subtotal": 0,
"total": 31
},
"msg": "OK (unknown bytes)",
"redirected": false,
"server": "Apache/2.4.6 (Red Hat Enterprise Linux)",
"set_cookie": "_session_id=; path=/; secure; HttpOnly; SameSite=Lax",
"status": 200,
"strict_transport_security": "max-age=631139040; includeSubdomains",
"transfer_encoding": "chunked",
"url": "https://satellite.example.com/api/v2/compute_profiles",
"vary": "Accept-Encoding",
"x_content_type_options": "nosniff",
"x_download_options": "noopen",
"x_frame_options": "sameorigin",
"x_permitted_cross_domain_policies": "none",
"x_powered_by": "Phusion Passenger 4.0.18",
"x_request_id": "",
"x_runtime": "0.038856",
"x_xss_protection": "1; mode=block"
}
TASK [ahuffman.sat6_create_hosts : debug] *************************************************************************************************************************************************************************************************************************************
task path: /ansible-galaxy-roles/ahuffman.sat6_create_hosts/tasks/create_host.yml:202
ok: [localhost] => {
"compute_profile_qry.json.results[0]": "VARIABLE IS NOT DEFINED!: list object has no element 0"
}
`
And this is the playbook:
`
Are the special characters "+"and "-" are a problem, beause "results": [],
?
Thank you in advance,
tuxnice
The block that actually creates the VMs doesn't have a check between building and powering on. If the VM hasn't finished building it errors out.
A hack of adding in a pause there works. A better solution would be a check to see if the VM has finished building. Not sure if this can be done from the Satellite API, or if it would have to come from the infrastructure.
Hi,
I have trouble deplyong a host in a nested group. Deyploing within the parent group is no problem, but when I give him the subgroup it fails with something like this:
"json": {
"error": {
"errors": {
"architecture_id": [
"can't be blank"
],
"medium_id": [
"can't be blank"
],
"operatingsystem_id": [
"can't be blank"
],
"ptable_id": [
"can't be blank unless a custom partition has been defined"
],
"root_pass": [
"should be 8 characters or more",
"should not be blank - consider setting a global or host group default"
]
},
"full_messages": [
"Operatingsystem can't be blank",
"Architecture can't be blank",
"Root password should be 8 characters or more",
"Root password should not be blank - consider setting a global or host group default",
"Partition Table can't be blank unless a custom partition has been defined",
"Medium can't be blank"
],
"id": null
}
Even though all values are either set in the parent or overwritten in the subgroup.
Hi,
updated to your new update. I also upgraded satellite to 6.4 and recreated the compute ressource.
Now I get no error, but I get
"Host(s) already exist in Satellite6:",
But the host does not exist in satellite nor in vmware...
Here is my playbook:
---
- name: "Satellite 6 create new hosts"
hosts: "localhost"
tasks:
- name: "Provision Satellite 6 Hosts"
include_role:
name: "sat6_create_hosts"
vars:
sat6_fail_on_existing: False
sat6_hosts:
- name: "ctx-el7-99"
domain: "ctlm.de"
host_group: "Ansible/EL7"
location: "Nürnberg"
ipv4: "10.30.6.99"
compute_resource: "vcsa"
parameters:
- name: "kt_activation_keys"
value: "rhel7"
ansible-playbook run with -vv
log.txt
What parameters to use to trigger an image build instead of a network build? From the example, looks like we need to specify build_type but not sure what the value should be.
Found that when specifying subnet names during host creation that had spaces caused the subnet_id queries to fail.
Found that the search queries required further quoting to properly search by name in this case.
Do to some previous API query changes that were made in a previous release we inadvertently broke compute profile queries due to a conditional looking for the host group name vs title.
Hi,
following tested with commit 57a1b7c
Task "Obtain Satellite6 Location ID" stops with fatal:
"content": "{\"status\":400,\"error\":\"There was a problem in the JSON you submitted: 751: unexpected token at '{\\\"search\\\": 'name=\\\"Nürnberg\\\"'}'\"}",
I am not 100% sure what is happening, but are you sending a search data body?
I think Locations does not support this? https://theforeman.org/api/1.22/apidoc/v2/locations.html
The yaml files is this:
---
- name: "Satellite 6 create new hosts"
hosts: "localhost"
tasks:
- name: "Provision Satellite 6 Hosts"
include_role:
name: "sat6_create_hosts"
vars:
sat6_fail_on_existing: False
sat6_hosts:
- name: "dev-app-1"
domain: "mydomain.de"
host_group: "Ansible/API"
location: "Nürnberg"
ipv4: "XXX.XXX.XXX.XXX"
subnet: "255.255.255.128"
compute_resource: "vcsa"
compute_profile: "API APP"
parameters:
- name: "kt_activation_keys"
value: "rhel7"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.