Jooho.okd_generate_ansible_hosts
Ansible Role: Create Hosts File for OKD Installation
This role helps to create two files: the Ansible hosts file and the OKD parameters file.
By default, this role expects an okd_param
file that lists OKD parameters. It combines this file with host information from group host variables.
The Ansible hosts file is used for installing OKD, while the okd_param_official
file is created from the official inventory file in the OKD Git repository.
Details
- Creates an Ansible hosts file named
/etc/ansible/hosts_{{cluster_tag}}
and/etc/ansible/hosts
. - Generates the
okd_param_official
file from the official inventory.
Requirements
- None
Role Variables
Name | Default Value | Required | Description |
---|---|---|---|
okd_param_name |
okd_param |
No | Name of the OKD parameters file |
okd_official_param_name |
okd_param_official |
No | Name of the official OKD parameters file created from the Ansible hosts file |
okd_param_dir |
Undefined | Yes | Directory path where the OKD parameters file is located |
okd_official_ansible_hosts_name |
okd_official_hosts |
No | Name of the official Ansible hosts file stored under okd_param_dir |
cluster_tag |
Undefined | Yes | A tag for backup (e.g., OKD0311) |
reformat_vars_to_hosts |
true |
No | Set to false to convert the official hosts file to variable style |
Dependencies
- None
Common Prerequisites
- There must be a "masters/nodes/lb" group.
- Each node must have
openshift_node_group_name
set as a host variable from OKD 3.10.
Example Playbook - Create Ansible Hosts File for OKD
Prerequisites:
- An
okd_param
file must exist in{{ okd_param_dir }}
.
- name: Example Playbook
hosts: localhost
tasks:
- import_role:
name: ansible-role-generate-ansible-hosts-okd
vars:
okd_param_dir: /home/jooho/test
cluster_tag: OKD0311
Example Playbook - Create okd_param_official
Prerequisites:
- The
{{ okd_official_ansible_hosts_name }}
file must be present in{{ okd_param_dir }}
.
- name: Example Playbook
hosts: localhost
tasks:
- import_role:
name: ansible-role-generate-ansible-hosts-okd
vars:
okd_param_dir: /home/jooho/test
reformat_vars_to_hosts: false
Test Playbook - Create Ansible Hosts File for OKD
Before running this, ensure there's no "masters/nodes" group in your current Ansible hosts file. If there is, remove it.
- name: Example Playbook
hosts: localhost
pre_tasks:
- name: Create test okd_param
copy:
dest: /tmp/{{ okd_param_name }}
content: >
openshift_release: 3.11
- name: Add group - masters
add_host:
name: master1
groups: masters
openshift_node_group_name: master-group-test
- name: Add group - nodes
add_host:
name: node1
groups: nodes
openshift_node_group_name: node-group-test
tasks:
- import_role:
name: ansible-role-okd-generate-ansible-hosts
vars:
okd_param_dir: /tmp
cluster_tag: OKD0311
Check Output - /etc/ansible/hosts_OKD0311
Expected Result:
[OSEv3:children]
masters
etcd
nodes
[OSEv3:vars]
openshift_release=3.11
[masters]
master1
[etcd]
master1
[nodes]
node1 openshift_node_group_name='node-group-test'
Test Playbook - Generate okd_param_official
Before running this, ensure there's no "masters/nodes" group in your current Ansible hosts file. If there is, remove it.
- name: Example Playbook
hosts: localhost
pre_tasks:
- name: Create test okd_param
copy:
dest: /tmp/{{ okd_param_name }}
content: >
openshift_release=3.11
- name: Add group - masters
add_host:
name: master1
groups: masters
openshift_node_group_name: master-group-test
- name: Add group - nodes
add_host:
name: node1
groups: nodes
openshift_node_group_name: node-group-test
tasks:
- import_role:
name: ansible-role-okd-generate-ansible-hosts
vars:
okd_param_dir: /tmp
reformat_vars_to_hosts: false
Check Output - /tmp/okd_param_official
Expected Result:
openshift_release: 3.11
License
- BSD/MIT
Author Information
This role was created in 2018 by Jooho Lee.