###Clone the current testing repo/branch (v3-beta3 or configUpdatesMaster)
cd
git clone https://github.com/detiber/openshift-ansible.git -b v3-beta3
cd ~/openshift-ansible
###Create an inventory script for your cloud hosts: eventually we'll support dynamic inventories for some cloud providers, but for now we'll use a static inventory (./test_inventory is assumed)
[os:children]
os-masters
os-nodes
[os:vars]
ansible_ssh_user=cloud-user
ansible_sudo=true
openshift_debug_level=4
deployment_type=enterprise
# Only if using pre-release (internal) registry
openshift_registry_url=docker-buildvm-rhose.usersys.redhat.com:5000/openshift3_beta/ose-${component}:${version}
# Only if using pre-release (internal) puddle builds
openshift_additional_repos=[{'id': 'ose-devel', 'name': 'ose-devel', 'baseurl': 'http://buildvm-devops.usersys.redhat.com/puddle/build/OpenShiftEnterprise/3.0/latest/RH7-RHOSE-3.0/$basearch/os', 'enabled': 1}]
[os-masters]
10.3.9.45
[os-nodes]
10.3.9.36
10.3.9.42
[masters:children]
os-masters
[nodes:children]
os-nodes
Some notes about this inventory:
- all groups are prefixed with os since it is an OpenStack cloud, and also because it allows us to set the common variables between masters and nodes in the inventory without duplication
- ansible_ssh_user should be set to the default user in your cloud instance
- ansible_sudo should be ommited if ansible_ssh_user is root
- openshift_registry_url and openshift_additional_repos are used for overriding the default settings when testing against development builds, beta customers should not set these variables)
- The master and node IPs used are internal addresses, since this is an internal cloud, each instance is assigned an internal IP in the 172.16.x.x range as well. The value used should either the be externally accessible IP address for the instance or a DNS name that will resolve to the externally accessible IP for the host.
./test_facts.yml is assumed
---
- name: Gather facts for hosts
hosts: os
gather_facts: no
roles:
- openshift_facts
tasks:
- name: openshift facts
openshift_facts:
register: result
- debug: var=result
ansible-playbook -i test_inventory test_facts.yml
This will produce output similar to:
ok: [10.3.9.45] => {
"result": {
"ansible_facts": {
"openshift": {
"common": {
"hostname": "jdetiber-osev3-ansible-005dcfa6-27c6-463d-9b95-ef059579befd.os1.phx2.redhat.com",
"ip": "172.16.4.79",
"public_hostname": "jdetiber-osev3-ansible-005dcfa6-27c6-463d-9b95-ef059579befd.os1.phx2.redhat.com",
"public_ip": "10.3.9.45",
"use_openshift_sdn": true
},
"provider": {
... <snip> ...
}
}
},
"changed": false,
"invocation": {
"module_args": "",
"module_name": "openshift_facts"
}
}
}
ok: [10.3.9.42] => {
"result": {
"ansible_facts": {
"openshift": {
"common": {
"hostname": "jdetiber-osev3-ansible-c6ae8cdc-ba0b-4a81-bb37-14549893f9d3.os1.phx2.redhat.com",
"ip": "172.16.4.75",
"public_hostname": "jdetiber-osev3-ansible-c6ae8cdc-ba0b-4a81-bb37-14549893f9d3.os1.phx2.redhat.com",
"public_ip": "10.3.9.42",
"use_openshift_sdn": true
},
"provider": {
...<snip>...
}
}
},
"changed": false,
"invocation": {
"module_args": "",
"module_name": "openshift_facts"
}
}
}
ok: [10.3.9.36] => {
"result": {
"ansible_facts": {
"openshift": {
"common": {
"hostname": "jdetiber-osev3-ansible-bc39a3d3-cdd7-42fe-9c12-9fac9b0ec320.os1.phx2.redhat.com",
"ip": "172.16.4.73",
"public_hostname": "jdetiber-osev3-ansible-bc39a3d3-cdd7-42fe-9c12-9fac9b0ec320.os1.phx2.redhat.com",
"public_ip": "10.3.9.36",
"use_openshift_sdn": true
},
"provider": {
...<snip>...
}
}
},
"changed": false,
"invocation": {
"module_args": "",
"module_name": "openshift_facts"
}
}
}
Now, we want to verify the detected common settings to verify that they are what we expect them to be (if not, we can override them).
- hostname
- Should resolve to the internal ip from the instances themselves.
- openshift_hostname will override.
- ip
- Should be the internal ip of the instance.
- openshift_ip will override.
- public hostname
- Should resolve to the external ip from hosts outside of the cloud provider
- openshift_public_hostname will override.
- public_ip
- Should be the externally accessible ip associated with the instance
- openshift_public_ip will override
- use_openshift_sdn
- Should be true unless the cloud is GCE.
- openshift_use_openshift_sdn overrides
ansible-playbook -i test_inventory playbooks/byo/config.yml
@detiber : ansible-playbook -i test_inventory test_facts.yml is returning
ERROR: openshift_facts is not a legal parameter in an Ansible task or handler