summaryrefslogtreecommitdiffstats
path: root/playbooks
diff options
context:
space:
mode:
Diffstat (limited to 'playbooks')
-rw-r--r--playbooks/aws/ansible-tower/launch.yml2
-rw-r--r--playbooks/aws/openshift-cluster/config.yml1
-rw-r--r--playbooks/aws/openshift-cluster/launch.yml8
-rw-r--r--playbooks/aws/openshift-cluster/service.yml28
-rw-r--r--playbooks/aws/openshift-cluster/tasks/launch_instances.yml3
-rw-r--r--playbooks/aws/openshift-master/launch.yml10
-rw-r--r--playbooks/aws/openshift-node/config.yml1
-rw-r--r--playbooks/aws/openshift-node/launch.yml10
-rw-r--r--playbooks/aws/os2-atomic-proxy/config.yml20
-rw-r--r--playbooks/aws/os2-atomic-proxy/launch.yml97
-rw-r--r--playbooks/aws/os2-atomic-proxy/user_data.txt6
-rw-r--r--playbooks/aws/os2-atomic-proxy/vars.int.yml3
-rw-r--r--playbooks/aws/os2-atomic-proxy/vars.prod.yml3
-rw-r--r--playbooks/aws/os2-atomic-proxy/vars.stg.yml10
-rw-r--r--playbooks/aws/os2-atomic-proxy/vars.yml1
-rw-r--r--playbooks/byo/openshift-node/config.yml4
-rw-r--r--playbooks/common/openshift-cluster/create_services.yml8
-rw-r--r--playbooks/common/openshift-master/config.yml5
-rw-r--r--playbooks/common/openshift-master/service.yml18
-rw-r--r--playbooks/common/openshift-node/config.yml81
-rw-r--r--playbooks/common/openshift-node/service.yml18
-rw-r--r--playbooks/gce/openshift-cluster/config.yml1
-rw-r--r--playbooks/gce/openshift-cluster/launch.yml16
-rw-r--r--playbooks/gce/openshift-cluster/list.yml2
-rw-r--r--playbooks/gce/openshift-cluster/service.yml28
-rw-r--r--playbooks/gce/openshift-cluster/wip.yml26
-rw-r--r--playbooks/gce/openshift-node/config.yml1
-rw-r--r--playbooks/libvirt/openshift-cluster/config.yml1
-rw-r--r--playbooks/libvirt/openshift-cluster/service.yml32
-rw-r--r--playbooks/libvirt/openshift-cluster/tasks/launch_instances.yml12
-rw-r--r--playbooks/openstack/openshift-cluster/config.yml35
-rw-r--r--playbooks/openstack/openshift-cluster/files/heat_stack.yml149
-rw-r--r--playbooks/openstack/openshift-cluster/files/user-data7
l---------playbooks/openstack/openshift-cluster/filter_plugins (renamed from playbooks/aws/os2-atomic-proxy/filter_plugins)0
-rw-r--r--playbooks/openstack/openshift-cluster/launch.yml31
-rw-r--r--playbooks/openstack/openshift-cluster/list.yml24
l---------playbooks/openstack/openshift-cluster/roles (renamed from playbooks/aws/os2-atomic-proxy/roles)0
-rw-r--r--playbooks/openstack/openshift-cluster/tasks/configure_openstack.yml27
-rw-r--r--playbooks/openstack/openshift-cluster/tasks/launch_instances.yml48
-rw-r--r--playbooks/openstack/openshift-cluster/terminate.yml43
-rw-r--r--playbooks/openstack/openshift-cluster/update.yml18
-rw-r--r--playbooks/openstack/openshift-cluster/vars.yml39
42 files changed, 673 insertions, 204 deletions
diff --git a/playbooks/aws/ansible-tower/launch.yml b/playbooks/aws/ansible-tower/launch.yml
index c23bda3a0..4bcc8b8dc 100644
--- a/playbooks/aws/ansible-tower/launch.yml
+++ b/playbooks/aws/ansible-tower/launch.yml
@@ -22,7 +22,7 @@
group_id: "{{ oo_security_group_ids }}"
instance_type: c4.xlarge
image: "{{ rhel7_ami }}"
- count: "{{ oo_new_inst_names | oo_len }}"
+ count: "{{ oo_new_inst_names | length }}"
user_data: "{{ lookup('file', user_data_file) }}"
wait: yes
assign_public_ip: "{{ oo_assign_public_ip }}"
diff --git a/playbooks/aws/openshift-cluster/config.yml b/playbooks/aws/openshift-cluster/config.yml
index b8961704e..7188312ed 100644
--- a/playbooks/aws/openshift-cluster/config.yml
+++ b/playbooks/aws/openshift-cluster/config.yml
@@ -32,5 +32,6 @@
openshift_cluster_id: "{{ cluster_id }}"
openshift_debug_level: 4
openshift_deployment_type: "{{ deployment_type }}"
+ openshift_first_master: "{{ groups.oo_first_master.0 }}"
openshift_hostname: "{{ ec2_private_ip_address }}"
openshift_public_hostname: "{{ ec2_ip_address }}"
diff --git a/playbooks/aws/openshift-cluster/launch.yml b/playbooks/aws/openshift-cluster/launch.yml
index 3eb5496e4..33e1ec25d 100644
--- a/playbooks/aws/openshift-cluster/launch.yml
+++ b/playbooks/aws/openshift-cluster/launch.yml
@@ -25,6 +25,14 @@
cluster: "{{ cluster_id }}"
type: "{{ k8s_type }}"
+ - set_fact:
+ a_master: "{{ master_names[0] }}"
+ - add_host: name={{ a_master }} groups=service_master
+
- include: update.yml
+- include: ../../common/openshift-cluster/create_services.yml
+ vars:
+ g_svc_master: "{{ service_master }}"
+
- include: list.yml
diff --git a/playbooks/aws/openshift-cluster/service.yml b/playbooks/aws/openshift-cluster/service.yml
new file mode 100644
index 000000000..25cf48505
--- /dev/null
+++ b/playbooks/aws/openshift-cluster/service.yml
@@ -0,0 +1,28 @@
+---
+- name: Call same systemctl command for openshift on all instance(s)
+ hosts: localhost
+ gather_facts: no
+ vars_files:
+ - vars.yml
+ tasks:
+ - fail: msg="cluster_id is required to be injected in this playbook"
+ when: cluster_id is not defined
+
+ - name: Evaluate g_service_masters
+ add_host:
+ name: "{{ item }}"
+ groups: g_service_masters
+ ansible_ssh_user: "{{ deployment_vars[deployment_type].ssh_user }}"
+ ansible_sudo: "{{ deployment_vars[deployment_type].sudo }}"
+ with_items: groups["tag_env-host-type_{{ cluster_id }}-openshift-master"] | default([])
+
+ - name: Evaluate g_service_nodes
+ add_host:
+ name: "{{ item }}"
+ groups: g_service_nodes
+ ansible_ssh_user: "{{ deployment_vars[deployment_type].ssh_user }}"
+ ansible_sudo: "{{ deployment_vars[deployment_type].sudo }}"
+ with_items: groups["tag_env-host-type_{{ cluster_id }}-openshift-node"] | default([])
+
+- include: ../../common/openshift-node/service.yml
+- include: ../../common/openshift-master/service.yml
diff --git a/playbooks/aws/openshift-cluster/tasks/launch_instances.yml b/playbooks/aws/openshift-cluster/tasks/launch_instances.yml
index 666a8d1fb..060147659 100644
--- a/playbooks/aws/openshift-cluster/tasks/launch_instances.yml
+++ b/playbooks/aws/openshift-cluster/tasks/launch_instances.yml
@@ -79,13 +79,14 @@
group: "{{ ec2_security_groups }}"
instance_type: "{{ ec2_instance_type }}"
image: "{{ latest_ami }}"
- count: "{{ instances | oo_len }}"
+ count: "{{ instances | length }}"
vpc_subnet_id: "{{ ec2_vpc_subnet | default(omit, true) }}"
assign_public_ip: "{{ ec2_assign_public_ip | default(omit, true) }}"
user_data: "{{ user_data }}"
wait: yes
instance_tags:
created-by: "{{ created_by }}"
+ environment: "{{ env }}"
env: "{{ env }}"
host-type: "{{ host_type }}"
env-host-type: "{{ env_host_type }}"
diff --git a/playbooks/aws/openshift-master/launch.yml b/playbooks/aws/openshift-master/launch.yml
index 6b3751682..1cefad492 100644
--- a/playbooks/aws/openshift-master/launch.yml
+++ b/playbooks/aws/openshift-master/launch.yml
@@ -4,10 +4,10 @@
connection: local
gather_facts: no
-# TODO: modify atomic_ami based on deployment_type
+# TODO: modify g_ami based on deployment_type
vars:
inst_region: us-east-1
- atomic_ami: ami-86781fee
+ g_ami: ami-86781fee
user_data_file: user_data.txt
tasks:
@@ -18,13 +18,13 @@
keypair: libra
group: ['public']
instance_type: m3.large
- image: "{{ atomic_ami }}"
- count: "{{ oo_new_inst_names | oo_len }}"
+ image: "{{ g_ami }}"
+ count: "{{ oo_new_inst_names | length }}"
user_data: "{{ lookup('file', user_data_file) }}"
wait: yes
register: ec2
- - name: Add new instances public IPs to the atomic proxy host group
+ - name: Add new instances public IPs to the host group
add_host: "hostname={{ item.public_ip }} groupname=new_ec2_instances"
with_items: ec2.instances
diff --git a/playbooks/aws/openshift-node/config.yml b/playbooks/aws/openshift-node/config.yml
index fc9b397b4..a993a1e99 100644
--- a/playbooks/aws/openshift-node/config.yml
+++ b/playbooks/aws/openshift-node/config.yml
@@ -21,5 +21,6 @@
openshift_cluster_id: "{{ cluster_id }}"
openshift_debug_level: 4
openshift_deployment_type: "{{ deployment_type }}"
+ openshift_first_master: "{{ groups.oo_first_master.0 }}"
openshift_hostname: "{{ ec2_private_ip_address }}"
openshift_public_hostname: "{{ ec2_ip_address }}"
diff --git a/playbooks/aws/openshift-node/launch.yml b/playbooks/aws/openshift-node/launch.yml
index 36aee14ff..e7d1f7310 100644
--- a/playbooks/aws/openshift-node/launch.yml
+++ b/playbooks/aws/openshift-node/launch.yml
@@ -4,10 +4,10 @@
connection: local
gather_facts: no
-# TODO: modify atomic_ami based on deployment_type
+# TODO: modify g_ami based on deployment_type
vars:
inst_region: us-east-1
- atomic_ami: ami-86781fee
+ g_ami: ami-86781fee
user_data_file: user_data.txt
tasks:
@@ -18,13 +18,13 @@
keypair: libra
group: ['public']
instance_type: m3.large
- image: "{{ atomic_ami }}"
- count: "{{ oo_new_inst_names | oo_len }}"
+ image: "{{ g_ami }}"
+ count: "{{ oo_new_inst_names | length }}"
user_data: "{{ lookup('file', user_data_file) }}"
wait: yes
register: ec2
- - name: Add new instances public IPs to the atomic proxy host group
+ - name: Add new instances public IPs to the host group
add_host:
hostname: "{{ item.public_ip }}"
groupname: new_ec2_instances"
diff --git a/playbooks/aws/os2-atomic-proxy/config.yml b/playbooks/aws/os2-atomic-proxy/config.yml
deleted file mode 100644
index 7d384a665..000000000
--- a/playbooks/aws/os2-atomic-proxy/config.yml
+++ /dev/null
@@ -1,20 +0,0 @@
----
-- name: "populate oo_hosts_to_config host group if needed"
- hosts: localhost
- gather_facts: no
- tasks:
- - name: Evaluate oo_host_group_exp if it's set
- add_host: "name={{ item }} groups=oo_hosts_to_config"
- with_items: "{{ oo_host_group_exp | default(['']) }}"
- when: oo_host_group_exp is defined
-
-- name: "Configure instances"
- hosts: oo_hosts_to_config
- connection: ssh
- user: root
- vars_files:
- - vars.yml
- - "vars.{{ oo_env }}.yml"
- roles:
- - atomic_base
- - atomic_proxy
diff --git a/playbooks/aws/os2-atomic-proxy/launch.yml b/playbooks/aws/os2-atomic-proxy/launch.yml
deleted file mode 100644
index fd6b0f39a..000000000
--- a/playbooks/aws/os2-atomic-proxy/launch.yml
+++ /dev/null
@@ -1,97 +0,0 @@
----
-- name: Launch instance(s)
- hosts: localhost
- connection: local
- gather_facts: no
-
- vars:
- inst_region: us-east-1
- atomic_ami: ami-8e239fe6
- user_data_file: user_data.txt
- oo_vpc_subnet_id: # Purposely left blank, these are here to be overridden in env vars_files
- oo_assign_public_ip: # Purposely left blank, these are here to be overridden in env vars_files
-
- vars_files:
- - vars.yml
- - "vars.{{ oo_env }}.yml"
-
- tasks:
- - name: Launch instances in VPC
- ec2:
- state: present
- region: "{{ inst_region }}"
- keypair: mmcgrath_libra
- group_id: "{{ oo_security_group_ids }}"
- instance_type: m3.large
- image: "{{ atomic_ami }}"
- count: "{{ oo_new_inst_names | oo_len }}"
- user_data: "{{ lookup('file', user_data_file) }}"
- wait: yes
- assign_public_ip: "{{ oo_assign_public_ip }}"
- vpc_subnet_id: "{{ oo_vpc_subnet_id }}"
- when: oo_vpc_subnet_id
- register: ec2_vpc
-
- - set_fact:
- ec2: "{{ ec2_vpc }}"
- when: oo_vpc_subnet_id
-
- - name: Launch instances in Classic
- ec2:
- state: present
- region: "{{ inst_region }}"
- keypair: mmcgrath_libra
- group: ['Libra', '{{ oo_env }}', '{{ oo_env }}_proxy', '{{ oo_env }}_proxy_atomic']
- instance_type: m3.large
- image: "{{ atomic_ami }}"
- count: "{{ oo_new_inst_names | oo_len }}"
- user_data: "{{ lookup('file', user_data_file) }}"
- wait: yes
- when: not oo_vpc_subnet_id
- register: ec2_classic
-
- - set_fact:
- ec2: "{{ ec2_classic }}"
- when: not oo_vpc_subnet_id
-
- - name: Add new instances public IPs to the atomic proxy host group
- add_host: "hostname={{ item.public_ip }} groupname=new_ec2_instances"
- with_items: ec2.instances
-
- - name: Add Name and environment tags to instances
- ec2_tag: "resource={{ item.1.id }} region={{ inst_region }} state=present"
- with_together:
- - oo_new_inst_names
- - ec2.instances
- args:
- tags:
- Name: "{{ item.0 }}"
-
- - name: Add other tags to instances
- ec2_tag: "resource={{ item.id }} region={{ inst_region }} state=present"
- with_items: ec2.instances
- args:
- tags: "{{ oo_new_inst_tags }}"
-
- - name: Add new instances public IPs to oo_hosts_to_config
- add_host: "hostname={{ item.0 }} ansible_ssh_host={{ item.1.public_ip }} groupname=oo_hosts_to_config"
- with_together:
- - oo_new_inst_names
- - ec2.instances
-
- - debug: var=ec2
-
- - name: Wait for ssh
- wait_for: "port=22 host={{ item.public_ip }}"
- with_items: ec2.instances
-
- - name: Wait for root user setup
- command: "ssh -o StrictHostKeyChecking=no -o PasswordAuthentication=no -o ConnectTimeout=10 -o UserKnownHostsFile=/dev/null root@{{ item.public_ip }} echo root user is setup"
- register: result
- until: result.rc == 0
- retries: 20
- delay: 10
- with_items: ec2.instances
-
-# Apply the configs, seprate so that just the configs can be run by themselves
-- include: config.yml
diff --git a/playbooks/aws/os2-atomic-proxy/user_data.txt b/playbooks/aws/os2-atomic-proxy/user_data.txt
deleted file mode 100644
index 643d17c32..000000000
--- a/playbooks/aws/os2-atomic-proxy/user_data.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-#cloud-config
-disable_root: 0
-
-system_info:
- default_user:
- name: root
diff --git a/playbooks/aws/os2-atomic-proxy/vars.int.yml b/playbooks/aws/os2-atomic-proxy/vars.int.yml
deleted file mode 100644
index 00157cd89..000000000
--- a/playbooks/aws/os2-atomic-proxy/vars.int.yml
+++ /dev/null
@@ -1,3 +0,0 @@
----
-oo_env_long: integration
-oo_zabbix_hostgroups: ['INT Environment']
diff --git a/playbooks/aws/os2-atomic-proxy/vars.prod.yml b/playbooks/aws/os2-atomic-proxy/vars.prod.yml
deleted file mode 100644
index 641afc626..000000000
--- a/playbooks/aws/os2-atomic-proxy/vars.prod.yml
+++ /dev/null
@@ -1,3 +0,0 @@
----
-oo_env_long: production
-oo_zabbix_hostgroups: ['PROD Environment']
diff --git a/playbooks/aws/os2-atomic-proxy/vars.stg.yml b/playbooks/aws/os2-atomic-proxy/vars.stg.yml
deleted file mode 100644
index 1cecfc9b2..000000000
--- a/playbooks/aws/os2-atomic-proxy/vars.stg.yml
+++ /dev/null
@@ -1,10 +0,0 @@
----
-oo_env_long: staging
-oo_zabbix_hostgroups: ['STG Environment']
-oo_vpc_subnet_id: subnet-700bdd07
-oo_assign_public_ip: yes
-oo_security_group_ids:
- - sg-02c2f267 # Libra (vpc)
- - sg-f0bfbe95 # stg (vpc)
- - sg-a3bfbec6 # stg_proxy (vpc)
- - sg-d4bfbeb1 # stg_proxy_atomic (vpc)
diff --git a/playbooks/aws/os2-atomic-proxy/vars.yml b/playbooks/aws/os2-atomic-proxy/vars.yml
deleted file mode 100644
index ed97d539c..000000000
--- a/playbooks/aws/os2-atomic-proxy/vars.yml
+++ /dev/null
@@ -1 +0,0 @@
----
diff --git a/playbooks/byo/openshift-node/config.yml b/playbooks/byo/openshift-node/config.yml
index d569827b4..f50903061 100644
--- a/playbooks/byo/openshift-node/config.yml
+++ b/playbooks/byo/openshift-node/config.yml
@@ -10,12 +10,14 @@
with_items: groups.nodes
- name: Evaluate oo_first_master
add_host:
- name: "{{ groups.masters[0] }}"
+ name: "{{ item }}"
groups: oo_first_master
+ with_items: groups.masters.0
- include: ../../common/openshift-node/config.yml
vars:
+ openshift_first_master: "{{ groups.masters.0 }}"
openshift_cluster_id: "{{ cluster_id | default('default') }}"
openshift_debug_level: 4
openshift_deployment_type: "{{ deployment_type }}"
diff --git a/playbooks/common/openshift-cluster/create_services.yml b/playbooks/common/openshift-cluster/create_services.yml
new file mode 100644
index 000000000..e70709d19
--- /dev/null
+++ b/playbooks/common/openshift-cluster/create_services.yml
@@ -0,0 +1,8 @@
+---
+- name: Deploy OpenShift Services
+ hosts: "{{ g_svc_master }}"
+ connection: ssh
+ gather_facts: yes
+ roles:
+ - openshift_registry
+ - openshift_router
diff --git a/playbooks/common/openshift-master/config.yml b/playbooks/common/openshift-master/config.yml
index 05822d118..052ed14c7 100644
--- a/playbooks/common/openshift-master/config.yml
+++ b/playbooks/common/openshift-master/config.yml
@@ -1,11 +1,10 @@
---
- name: Configure master instances
hosts: oo_masters_to_config
- vars:
- openshift_sdn_master_url: https://{{ openshift.common.hostname }}:4001
roles:
- openshift_master
- - { role: openshift_sdn_master, when: openshift.common.use_openshift_sdn | bool }
+ - role: fluentd_master
+ when: openshift.common.use_fluentd | bool
tasks:
- name: Create group for deployment type
group_by: key=oo_masters_deployment_type_{{ openshift.common.deployment_type }}
diff --git a/playbooks/common/openshift-master/service.yml b/playbooks/common/openshift-master/service.yml
new file mode 100644
index 000000000..5636ad156
--- /dev/null
+++ b/playbooks/common/openshift-master/service.yml
@@ -0,0 +1,18 @@
+---
+- name: Populate g_service_masters host group if needed
+ hosts: localhost
+ gather_facts: no
+ tasks:
+ - fail: msg="new_cluster_state is required to be injected in this playbook"
+ when: new_cluster_state is not defined
+
+ - name: Evaluate g_service_masters
+ add_host: name={{ item }} groups=g_service_masters
+ with_items: oo_host_group_exp | default([])
+
+- name: Change openshift-master state on master instance(s)
+ hosts: g_service_masters
+ connection: ssh
+ gather_facts: no
+ tasks:
+ - service: name=openshift-master state="{{ new_cluster_state }}"
diff --git a/playbooks/common/openshift-node/config.yml b/playbooks/common/openshift-node/config.yml
index 96641a274..9e642f3d3 100644
--- a/playbooks/common/openshift-node/config.yml
+++ b/playbooks/common/openshift-node/config.yml
@@ -4,9 +4,9 @@
roles:
- openshift_facts
tasks:
- # Since the master is registering the nodes before they are configured, we
- # need to make sure to set the node properties beforehand if we do not want
- # the defaults
+ # Since the master is generating the node certificates before they are
+ # configured, we need to make sure to set the node properties beforehand if
+ # we do not want the defaults
- openshift_facts:
role: "{{ item.role }}"
local_facts: "{{ item.local_facts }}"
@@ -18,13 +18,26 @@
deployment_type: "{{ openshift_deployment_type }}"
- role: node
local_facts:
- external_id: "{{ openshift_node_external_id | default(None) }}"
resources_cpu: "{{ openshift_node_resources_cpu | default(None) }}"
resources_memory: "{{ openshift_node_resources_memory | default(None) }}"
pod_cidr: "{{ openshift_node_pod_cidr | default(None) }}"
labels: "{{ openshift_node_labels | default(None) }}"
annotations: "{{ openshift_node_annotations | default(None) }}"
-
+ - name: Check status of node certificates
+ stat:
+ path: "{{ item }}"
+ with_items:
+ - "/etc/openshift/node/node.key"
+ - "/etc/openshift/node/node.kubeconfig"
+ - "/etc/openshift/node/ca.crt"
+ - "/etc/openshift/node/server.key"
+ register: stat_result
+ - set_fact:
+ certs_missing: "{{ stat_result.results | map(attribute='stat.exists')
+ | list | intersect([false])}}"
+ node_subdir: node-{{ openshift.common.hostname }}
+ config_dir: /etc/openshift/generated-configs/node-{{ openshift.common.hostname }}
+ node_cert_dir: /etc/openshift/node
- name: Create temp directory for syncing certs
hosts: localhost
@@ -37,65 +50,59 @@
register: mktemp
changed_when: False
-
- name: Register nodes
hosts: oo_first_master
vars:
- openshift_nodes: "{{ hostvars | oo_select_keys(groups['oo_nodes_to_config']) }}"
+ nodes_needing_certs: "{{ hostvars
+ | oo_select_keys(groups['oo_nodes_to_config'])
+ | oo_filter_list(filter_attr='certs_missing') }}"
+ openshift_nodes: "{{ hostvars
+ | oo_select_keys(groups['oo_nodes_to_config']) }}"
sync_tmpdir: "{{ hostvars.localhost.mktemp.stdout }}"
roles:
- openshift_register_nodes
- tasks:
- # TODO: update so that we only sync necessary configs/directories, currently
- # we sync for all nodes in oo_nodes_to_config. We will need to inspect the
- # configs on the nodes to make the determination on whether to sync or not.
- - name: Create the temp directory on the master
- file:
- path: "{{ sync_tmpdir }}"
- owner: "{{ ansible_ssh_user }}"
- mode: 0700
- state: directory
- changed_when: False
-
+ post_tasks:
- name: Create a tarball of the node config directories
- command: tar -czvf {{ sync_tmpdir }}/{{ item.openshift.common.hostname }}.tgz ./
+ command: >
+ tar -czvf {{ item.config_dir }}.tgz
+ --transform 's|system:{{ item.node_subdir }}|node|'
+ -C {{ item.config_dir }} .
args:
- chdir: "{{ openshift_cert_dir }}/node-{{ item.openshift.common.hostname }}"
- with_items: openshift_nodes
- changed_when: False
+ creates: "{{ item.config_dir }}.tgz"
+ with_items: nodes_needing_certs
- name: Retrieve the node config tarballs from the master
fetch:
- src: "{{ sync_tmpdir }}/{{ item.openshift.common.hostname }}.tgz"
+ src: "{{ item.config_dir }}.tgz"
dest: "{{ sync_tmpdir }}/"
+ flat: yes
fail_on_missing: yes
validate_checksum: yes
- with_items: openshift_nodes
- changed_when: False
-
+ with_items: nodes_needing_certs
- name: Configure node instances
hosts: oo_nodes_to_config
- gather_facts: no
vars:
- sync_tmpdir: "{{ hostvars.localhost.mktemp.stdout }}/{{ groups['oo_first_master'][0] }}/{{ hostvars.localhost.mktemp.stdout }}"
- openshift_sdn_master_url: "https://{{ hostvars[groups['oo_first_master'][0]].openshift.common.hostname }}:4001"
+ sync_tmpdir: "{{ hostvars.localhost.mktemp.stdout }}"
+ openshift_node_master_api_url: "{{ hostvars[openshift_first_master].openshift.master.api_url }}"
pre_tasks:
- name: Ensure certificate directory exists
file:
- path: "{{ openshift_node_cert_dir }}"
+ path: "{{ node_cert_dir }}"
state: directory
- # TODO: notify restart openshift-node and/or restart openshift-sdn-node,
+ # TODO: notify restart openshift-node
# possibly test service started time against certificate/config file
- # timestamps in openshift-node or openshift-sdn-node to trigger notify
+ # timestamps in openshift-node to trigger notify
- name: Unarchive the tarball on the node
unarchive:
- src: "{{ sync_tmpdir }}/{{ openshift.common.hostname }}.tgz"
- dest: "{{ openshift_node_cert_dir }}"
+ src: "{{ sync_tmpdir }}/{{ node_subdir }}.tgz"
+ dest: "{{ node_cert_dir }}"
+ when: certs_missing
roles:
- openshift_node
- - { role: openshift_sdn_node, when: openshift.common.use_openshift_sdn | bool }
+ - role: fluentd_node
+ when: openshift.common.use_fluentd | bool
tasks:
- name: Create group for deployment type
group_by: key=oo_nodes_deployment_type_{{ openshift.common.deployment_type }}
@@ -110,7 +117,6 @@
- file: name={{ sync_tmpdir }} state=absent
changed_when: False
-
- name: Delete temporary directory on localhost
hosts: localhost
connection: local
@@ -120,7 +126,6 @@
- file: name={{ mktemp.stdout }} state=absent
changed_when: False
-
# Additional config for online type deployments
- name: Additional instance config
hosts: oo_nodes_deployment_type_online
diff --git a/playbooks/common/openshift-node/service.yml b/playbooks/common/openshift-node/service.yml
new file mode 100644
index 000000000..f76df089f
--- /dev/null
+++ b/playbooks/common/openshift-node/service.yml
@@ -0,0 +1,18 @@
+---
+- name: Populate g_service_nodes host group if needed
+ hosts: localhost
+ gather_facts: no
+ tasks:
+ - fail: msg="new_cluster_state is required to be injected in this playbook"
+ when: new_cluster_state is not defined
+
+ - name: Evaluate g_service_nodes
+ add_host: name={{ item }} groups=g_service_nodes
+ with_items: oo_host_group_exp | default([])
+
+- name: Change openshift-node state on node instance(s)
+ hosts: g_service_nodes
+ connection: ssh
+ gather_facts: no
+ tasks:
+ - service: name=openshift-node state="{{ new_cluster_state }}"
diff --git a/playbooks/gce/openshift-cluster/config.yml b/playbooks/gce/openshift-cluster/config.yml
index 8b8490246..8c320dbd2 100644
--- a/playbooks/gce/openshift-cluster/config.yml
+++ b/playbooks/gce/openshift-cluster/config.yml
@@ -34,4 +34,5 @@
openshift_cluster_id: "{{ cluster_id }}"
openshift_debug_level: 4
openshift_deployment_type: "{{ deployment_type }}"
+ openshift_first_master: "{{ groups.oo_first_master.0 }}"
openshift_hostname: "{{ gce_private_ip }}"
diff --git a/playbooks/gce/openshift-cluster/launch.yml b/playbooks/gce/openshift-cluster/launch.yml
index 771f51e91..35737f03d 100644
--- a/playbooks/gce/openshift-cluster/launch.yml
+++ b/playbooks/gce/openshift-cluster/launch.yml
@@ -23,6 +23,22 @@
cluster: "{{ cluster_id }}"
type: "{{ k8s_type }}"
+ - set_fact:
+ a_master: "{{ master_names[0] }}"
+ - add_host: name={{ a_master }} groups=service_master
+
- include: update.yml
+- name: Deploy OpenShift Services
+ hosts: service_master
+ connection: ssh
+ gather_facts: yes
+ roles:
+ - openshift_registry
+ - openshift_router
+
+- include: ../../common/openshift-cluster/create_services.yml
+ vars:
+ g_svc_master: "{{ service_master }}"
+
- include: list.yml
diff --git a/playbooks/gce/openshift-cluster/list.yml b/playbooks/gce/openshift-cluster/list.yml
index 962381306..5ba0f5a48 100644
--- a/playbooks/gce/openshift-cluster/list.yml
+++ b/playbooks/gce/openshift-cluster/list.yml
@@ -16,7 +16,7 @@
ansible_sudo: "{{ deployment_vars[deployment_type].sudo }}"
with_items: groups[scratch_group] | default([]) | difference(['localhost']) | difference(groups.status_terminated)
-- name: List Hosts
+- name: List instance(s)
hosts: oo_list_hosts
gather_facts: no
tasks:
diff --git a/playbooks/gce/openshift-cluster/service.yml b/playbooks/gce/openshift-cluster/service.yml
new file mode 100644
index 000000000..2d0f2ab95
--- /dev/null
+++ b/playbooks/gce/openshift-cluster/service.yml
@@ -0,0 +1,28 @@
+---
+- name: Call same systemctl command for openshift on all instance(s)
+ hosts: localhost
+ gather_facts: no
+ vars_files:
+ - vars.yml
+ tasks:
+ - fail: msg="cluster_id is required to be injected in this playbook"
+ when: cluster_id is not defined
+
+ - set_fact: scratch_group=tag_env-host-type-{{ cluster_id }}-openshift-node
+ - add_host:
+ name: "{{ item }}"
+ groups: g_service_nodes
+ ansible_ssh_user: "{{ deployment_vars[deployment_type].ssh_user | default(ansible_ssh_user, true) }}"
+ ansible_sudo: "{{ deployment_vars[deployment_type].sudo }}"
+ with_items: groups[scratch_group] | default([]) | difference(['localhost']) | difference(groups.status_terminated)
+
+ - set_fact: scratch_group=tag_env-host-type-{{ cluster_id }}-openshift-master
+ - add_host:
+ name: "{{ item }}"
+ groups: g_service_masters
+ ansible_ssh_user: "{{ deployment_vars[deployment_type].ssh_user | default(ansible_ssh_user, true) }}"
+ ansible_sudo: "{{ deployment_vars[deployment_type].sudo }}"
+ with_items: groups[scratch_group] | default([]) | difference(['localhost']) | difference(groups.status_terminated)
+
+- include: ../../common/openshift-node/service.yml
+- include: ../../common/openshift-master/service.yml
diff --git a/playbooks/gce/openshift-cluster/wip.yml b/playbooks/gce/openshift-cluster/wip.yml
new file mode 100644
index 000000000..51a521a6b
--- /dev/null
+++ b/playbooks/gce/openshift-cluster/wip.yml
@@ -0,0 +1,26 @@
+---
+- name: WIP
+ hosts: localhost
+ connection: local
+ gather_facts: no
+ vars_files:
+ - vars.yml
+ tasks:
+ - name: Evaluate oo_masters_for_deploy
+ add_host:
+ name: "{{ item }}"
+ groups: oo_masters_for_deploy
+ ansible_ssh_user: "{{ deployment_vars[deployment_type].ssh_user | default(ansible_ssh_user, true) }}"
+ ansible_sudo: "{{ deployment_vars[deployment_type].sudo }}"
+ with_items: groups["tag_env-host-type-{{ cluster_id }}-openshift-master"] | default([])
+
+- name: Deploy OpenShift Services
+ hosts: oo_masters_for_deploy
+ connection: ssh
+ gather_facts: yes
+ user: root
+ vars_files:
+ - vars.yml
+ roles:
+ - openshift_registry
+ - openshift_router
diff --git a/playbooks/gce/openshift-node/config.yml b/playbooks/gce/openshift-node/config.yml
index 5b1601176..54b0da2ca 100644
--- a/playbooks/gce/openshift-node/config.yml
+++ b/playbooks/gce/openshift-node/config.yml
@@ -21,4 +21,5 @@
openshift_cluster_id: "{{ cluster_id }}"
openshift_debug_level: 4
openshift_deployment_type: "{{ deployment_type }}"
+ openshift_first_master: "{{ groups.oo_first_master.0 }}"
openshift_hostname: "{{ gce_private_ip }}"
diff --git a/playbooks/libvirt/openshift-cluster/config.yml b/playbooks/libvirt/openshift-cluster/config.yml
index faf278b10..75e2005a2 100644
--- a/playbooks/libvirt/openshift-cluster/config.yml
+++ b/playbooks/libvirt/openshift-cluster/config.yml
@@ -36,3 +36,4 @@
openshift_cluster_id: "{{ cluster_id }}"
openshift_debug_level: 4
openshift_deployment_type: "{{ deployment_type }}"
+ openshift_first_master: "{{ groups.oo_first_master.0 }}"
diff --git a/playbooks/libvirt/openshift-cluster/service.yml b/playbooks/libvirt/openshift-cluster/service.yml
new file mode 100644
index 000000000..ae095f5a2
--- /dev/null
+++ b/playbooks/libvirt/openshift-cluster/service.yml
@@ -0,0 +1,32 @@
+---
+# TODO: need to figure out a plan for setting hostname, currently the default
+# is localhost, so no hostname value (or public_hostname) value is getting
+# assigned
+
+- name: Call same systemctl command for openshift on all instance(s)
+ hosts: localhost
+ gather_facts: no
+ vars_files:
+ - vars.yml
+ tasks:
+ - fail: msg="cluster_id is required to be injected in this playbook"
+ when: cluster_id is not defined
+
+ - name: Evaluate g_service_masters
+ add_host:
+ name: "{{ item }}"
+ ansible_ssh_user: "{{ deployment_vars[deployment_type].ssh_user }}"
+ ansible_sudo: "{{ deployment_vars[deployment_type].sudo }}"
+ groups: g_service_masters
+ with_items: groups["tag_env-host-type-{{ cluster_id }}-openshift-master"] | default([])
+
+ - name: Evaluate g_service_nodes
+ add_host:
+ name: "{{ item }}"
+ ansible_ssh_user: "{{ deployment_vars[deployment_type].ssh_user }}"
+ ansible_sudo: "{{ deployment_vars[deployment_type].sudo }}"
+ groups: g_service_nodes
+ with_items: groups["tag_env-host-type-{{ cluster_id }}-openshift-node"] | default([])
+
+- include: ../../common/openshift-node/service.yml
+- include: ../../common/openshift-master/service.yml
diff --git a/playbooks/libvirt/openshift-cluster/tasks/launch_instances.yml b/playbooks/libvirt/openshift-cluster/tasks/launch_instances.yml
index 359d0b2f3..8291192ab 100644
--- a/playbooks/libvirt/openshift-cluster/tasks/launch_instances.yml
+++ b/playbooks/libvirt/openshift-cluster/tasks/launch_instances.yml
@@ -58,23 +58,17 @@
uri: '{{ libvirt_uri }}'
with_items: instances
-- name: Collect MAC addresses of the VMs
- shell: 'virsh -c {{ libvirt_uri }} dumpxml {{ item }} | xmllint --xpath "string(//domain/devices/interface/mac/@address)" -'
- register: scratch_mac
- with_items: instances
-
- name: Wait for the VMs to get an IP
- command: "egrep -c '{{ scratch_mac.results | oo_collect('stdout') | join('|') }}' /proc/net/arp"
- ignore_errors: yes
+ shell: 'virsh -c {{ libvirt_uri }} net-dhcp-leases openshift-ansible | egrep -c ''{{ instances | join("|") }}'''
register: nb_allocated_ips
until: nb_allocated_ips.stdout == '{{ instances | length }}'
retries: 30
delay: 1
- name: Collect IP addresses of the VMs
- shell: "awk '/{{ item.stdout }}/ {print $1}' /proc/net/arp"
+ shell: 'virsh -c {{ libvirt_uri }} net-dhcp-leases openshift-ansible | awk ''$6 == "{{ item }}" {gsub(/\/.*/, "", $5); print $5}'''
register: scratch_ip
- with_items: scratch_mac.results
+ with_items: instances
- set_fact:
ips: "{{ scratch_ip.results | oo_collect('stdout') }}"
diff --git a/playbooks/openstack/openshift-cluster/config.yml b/playbooks/openstack/openshift-cluster/config.yml
new file mode 100644
index 000000000..abadaf5ca
--- /dev/null
+++ b/playbooks/openstack/openshift-cluster/config.yml
@@ -0,0 +1,35 @@
+- name: Populate oo_masters_to_config host group
+ hosts: localhost
+ gather_facts: no
+ vars_files:
+ - vars.yml
+ tasks:
+ - name: Evaluate oo_masters_to_config
+ add_host:
+ name: "{{ item }}"
+ ansible_ssh_user: "{{ deployment_vars[deployment_type].ssh_user }}"
+ ansible_sudo: "{{ deployment_vars[deployment_type].sudo }}"
+ groups: oo_masters_to_config
+ with_items: groups["tag_env-host-type_{{ cluster_id }}-openshift-master"] | default([])
+ - name: Evaluate oo_nodes_to_config
+ add_host:
+ name: "{{ item }}"
+ ansible_ssh_user: "{{ deployment_vars[deployment_type].ssh_user }}"
+ ansible_sudo: "{{ deployment_vars[deployment_type].sudo }}"
+ groups: oo_nodes_to_config
+ with_items: groups["tag_env-host-type_{{ cluster_id }}-openshift-node"] | default([])
+ - name: Evaluate oo_first_master
+ add_host:
+ name: "{{ groups['tag_env-host-type_' ~ cluster_id ~ '-openshift-master'][0] }}"
+ ansible_ssh_user: "{{ deployment_vars[deployment_type].ssh_user }}"
+ ansible_sudo: "{{ deployment_vars[deployment_type].sudo }}"
+ groups: oo_first_master
+ when: "'tag_env-host-type_{{ cluster_id }}-openshift-master' in groups"
+
+- include: ../../common/openshift-cluster/config.yml
+ vars:
+ openshift_cluster_id: "{{ cluster_id }}"
+ openshift_debug_level: 4
+ openshift_deployment_type: "{{ deployment_type }}"
+ openshift_first_master: "{{ groups.oo_first_master.0 }}"
+ openshift_hostname: "{{ ansible_default_ipv4.address }}"
diff --git a/playbooks/openstack/openshift-cluster/files/heat_stack.yml b/playbooks/openstack/openshift-cluster/files/heat_stack.yml
new file mode 100644
index 000000000..c5f95d87d
--- /dev/null
+++ b/playbooks/openstack/openshift-cluster/files/heat_stack.yml
@@ -0,0 +1,149 @@
+heat_template_version: 2014-10-16
+
+description: OpenShift cluster
+
+parameters:
+ cluster-id:
+ type: string
+ label: Cluster ID
+ description: Identifier of the cluster
+
+ network-prefix:
+ type: string
+ label: Network prefix
+ description: Prefix of the network objects
+
+ cidr:
+ type: string
+ label: CIDR
+ description: CIDR of the network of the cluster
+
+ dns-nameservers:
+ type: comma_delimited_list
+ label: DNS nameservers list
+ description: List of DNS nameservers
+
+ external-net:
+ type: string
+ label: External network
+ description: Name of the external network
+ default: external
+
+ ssh-incoming:
+ type: string
+ label: Source of ssh connections
+ description: Source of legitimate ssh connections
+
+resources:
+ net:
+ type: OS::Neutron::Net
+ properties:
+ name:
+ str_replace:
+ template: network-prefix-net
+ params:
+ network-prefix: { get_param: network-prefix }
+
+ subnet:
+ type: OS::Neutron::Subnet
+ properties:
+ name:
+ str_replace:
+ template: network-prefix-subnet
+ params:
+ network-prefix: { get_param: network-prefix }
+ network: { get_resource: net }
+ cidr: { get_param: cidr }
+ dns_nameservers: { get_param: dns-nameservers }
+
+ router:
+ type: OS::Neutron::Router
+ properties:
+ name:
+ str_replace:
+ template: network-prefix-router
+ params:
+ network-prefix: { get_param: network-prefix }
+ external_gateway_info:
+ network: { get_param: external-net }
+
+ interface:
+ type: OS::Neutron::RouterInterface
+ properties:
+ router_id: { get_resource: router }
+ subnet_id: { get_resource: subnet }
+
+ node-secgrp:
+ type: OS::Neutron::SecurityGroup
+ properties:
+ name:
+ str_replace:
+ template: network-prefix-node-secgrp
+ params:
+ network-prefix: { get_param: network-prefix }
+ description:
+ str_replace:
+ template: Security group for cluster-id OpenShift cluster nodes
+ params:
+ cluster-id: { get_param: cluster-id }
+ rules:
+ - direction: ingress
+ protocol: tcp
+ port_range_min: 22
+ port_range_max: 22
+ remote_ip_prefix: { get_param: ssh-incoming }
+ - direction: ingress
+ protocol: udp
+ port_range_min: 4789
+ port_range_max: 4789
+ remote_mode: remote_group_id
+ - direction: ingress
+ protocol: tcp
+ port_range_min: 10250
+ port_range_max: 10250
+ remote_mode: remote_group_id
+ remote_group_id: { get_resource: master-secgrp }
+
+ master-secgrp:
+ type: OS::Neutron::SecurityGroup
+ properties:
+ name:
+ str_replace:
+ template: network-prefix-master-secgrp
+ params:
+ network-prefix: { get_param: network-prefix }
+ description:
+ str_replace:
+ template: Security group for cluster-id OpenShift cluster master
+ params:
+ cluster-id: { get_param: cluster-id }
+ rules:
+ - direction: ingress
+ protocol: tcp
+ port_range_min: 22
+ port_range_max: 22
+ remote_ip_prefix: { get_param: ssh-incoming }
+ - direction: ingress
+ protocol: tcp
+ port_range_min: 4001
+ port_range_max: 4001
+ - direction: ingress
+ protocol: tcp
+ port_range_min: 8443
+ port_range_max: 8443
+ - direction: ingress
+ protocol: tcp
+ port_range_min: 53
+ port_range_max: 53
+ - direction: ingress
+ protocol: udp
+ port_range_min: 53
+ port_range_max: 53
+ - direction: ingress
+ protocol: tcp
+ port_range_min: 24224
+ port_range_max: 24224
+ - direction: ingress
+ protocol: udp
+ port_range_min: 24224
+ port_range_max: 24224
diff --git a/playbooks/openstack/openshift-cluster/files/user-data b/playbooks/openstack/openshift-cluster/files/user-data
new file mode 100644
index 000000000..e789a5b69
--- /dev/null
+++ b/playbooks/openstack/openshift-cluster/files/user-data
@@ -0,0 +1,7 @@
+#cloud-config
+disable_root: true
+
+system_info:
+ default_user:
+ name: openshift
+ sudo: ["ALL=(ALL) NOPASSWD: ALL"]
diff --git a/playbooks/aws/os2-atomic-proxy/filter_plugins b/playbooks/openstack/openshift-cluster/filter_plugins
index 99a95e4ca..99a95e4ca 120000
--- a/playbooks/aws/os2-atomic-proxy/filter_plugins
+++ b/playbooks/openstack/openshift-cluster/filter_plugins
diff --git a/playbooks/openstack/openshift-cluster/launch.yml b/playbooks/openstack/openshift-cluster/launch.yml
new file mode 100644
index 000000000..5c86ade3f
--- /dev/null
+++ b/playbooks/openstack/openshift-cluster/launch.yml
@@ -0,0 +1,31 @@
+---
+- name: Launch instance(s)
+ hosts: localhost
+ connection: local
+ gather_facts: no
+ vars_files:
+ - vars.yml
+ tasks:
+ - fail:
+ msg: "Deployment type not supported for OpenStack provider yet"
+ when: deployment_type in ['online', 'enterprise']
+
+ - include: tasks/configure_openstack.yml
+
+ - include: ../../common/openshift-cluster/set_master_launch_facts_tasks.yml
+ - include: tasks/launch_instances.yml
+ vars:
+ instances: "{{ master_names }}"
+ cluster: "{{ cluster_id }}"
+ type: "{{ k8s_type }}"
+
+ - include: ../../common/openshift-cluster/set_node_launch_facts_tasks.yml
+ - include: tasks/launch_instances.yml
+ vars:
+ instances: "{{ node_names }}"
+ cluster: "{{ cluster_id }}"
+ type: "{{ k8s_type }}"
+
+- include: update.yml
+
+- include: list.yml
diff --git a/playbooks/openstack/openshift-cluster/list.yml b/playbooks/openstack/openshift-cluster/list.yml
new file mode 100644
index 000000000..a75e350c7
--- /dev/null
+++ b/playbooks/openstack/openshift-cluster/list.yml
@@ -0,0 +1,24 @@
+---
+- name: Generate oo_list_hosts group
+ hosts: localhost
+ gather_facts: no
+ vars_files:
+ - vars.yml
+ tasks:
+ - set_fact: scratch_group=tag_env_{{ cluster_id }}
+ when: cluster_id != ''
+ - set_fact: scratch_group=all
+ when: cluster_id == ''
+ - add_host:
+ name: "{{ item }}"
+ groups: oo_list_hosts
+ ansible_ssh_user: "{{ deployment_vars[deployment_type].ssh_user }}"
+ ansible_ssh_host: "{{ hostvars[item].ansible_ssh_host | default(item) }}"
+ ansible_sudo: "{{ deployment_vars[deployment_type].sudo }}"
+ with_items: groups[scratch_group] | default([]) | difference(['localhost'])
+
+- name: List Hosts
+ hosts: oo_list_hosts
+ tasks:
+ - debug:
+ msg: 'public:{{ansible_ssh_host}} private:{{ansible_default_ipv4.address}}'
diff --git a/playbooks/aws/os2-atomic-proxy/roles b/playbooks/openstack/openshift-cluster/roles
index 20c4c58cf..20c4c58cf 120000
--- a/playbooks/aws/os2-atomic-proxy/roles
+++ b/playbooks/openstack/openshift-cluster/roles
diff --git a/playbooks/openstack/openshift-cluster/tasks/configure_openstack.yml b/playbooks/openstack/openshift-cluster/tasks/configure_openstack.yml
new file mode 100644
index 000000000..2cbdb4805
--- /dev/null
+++ b/playbooks/openstack/openshift-cluster/tasks/configure_openstack.yml
@@ -0,0 +1,27 @@
+---
+- name: Check infra
+ command: 'heat stack-show {{ openstack_network_prefix }}-stack'
+ register: stack_show_result
+ changed_when: false
+ failed_when: stack_show_result.rc != 0 and 'Stack not found' not in stack_show_result.stderr
+
+- name: Create infra
+ command: 'heat stack-create -f {{ openstack_infra_heat_stack }} -P cluster-id={{ cluster_id }} -P network-prefix={{ openstack_network_prefix }} -P dns-nameservers={{ openstack_network_dns | join(",") }} -P cidr={{ openstack_network_cidr }} -P ssh-incoming={{ openstack_ssh_access_from }} {{ openstack_network_prefix }}-stack'
+ when: stack_show_result.rc == 1
+
+- name: Update infra
+ command: 'heat stack-update -f {{ openstack_infra_heat_stack }} -P cluster-id={{ cluster_id }} -P network-prefix={{ openstack_network_prefix }} -P dns-nameservers={{ openstack_network_dns | join(",") }} -P cidr={{ openstack_network_cidr }} -P ssh-incoming={{ openstack_ssh_access_from }} {{ openstack_network_prefix }}-stack'
+ when: stack_show_result.rc == 0
+
+- name: Wait for infra readiness
+ shell: 'heat stack-show {{ openstack_network_prefix }}-stack | awk ''$2 == "stack_status" {print $4}'''
+ register: stack_show_status_result
+ until: stack_show_status_result.stdout not in ['CREATE_IN_PROGRESS', 'UPDATE_IN_PROGRESS']
+ retries: 30
+ delay: 1
+ failed_when: stack_show_status_result.stdout not in ['CREATE_COMPLETE', 'UPDATE_COMPLETE']
+
+- name: Create ssh keypair
+ nova_keypair:
+ name: "{{ openstack_ssh_keypair }}"
+ public_key: "{{ openstack_ssh_public_key }}"
diff --git a/playbooks/openstack/openshift-cluster/tasks/launch_instances.yml b/playbooks/openstack/openshift-cluster/tasks/launch_instances.yml
new file mode 100644
index 000000000..1b9696aac
--- /dev/null
+++ b/playbooks/openstack/openshift-cluster/tasks/launch_instances.yml
@@ -0,0 +1,48 @@
+---
+- name: Get net id
+ shell: 'neutron net-show {{ openstack_network_prefix }}-net | awk "/\\<id\\>/ {print \$4}"'
+ register: net_id_result
+
+- name: Launch instance(s)
+ nova_compute:
+ name: '{{ item }}'
+ image_name: '{{ deployment_vars[deployment_type].image.name | default(omit, true) }}'
+ image_id: '{{ deployment_vars[deployment_type].image.id | default(omit, true) }}'
+ flavor_ram: '{{ openstack_flavor[k8s_type].ram | default(omit, true) }}'
+ flavor_id: '{{ openstack_flavor[k8s_type].id | default(omit, true) }}'
+ flavor_include: '{{ openstack_flavor[k8s_type].include | default(omit, true) }}'
+ key_name: '{{ openstack_ssh_keypair }}'
+ security_groups: '{{ openstack_network_prefix }}-{{ k8s_type }}-secgrp'
+ nics:
+ - net-id: '{{ net_id_result.stdout }}'
+ user_data: "{{ lookup('file','files/user-data') }}"
+ meta:
+ env: '{{ cluster }}'
+ host-type: '{{ type }}'
+ env-host-type: '{{ cluster }}-openshift-{{ type }}'
+ floating_ip_pools: '{{ openstack_floating_ip_pools }}'
+ with_items: instances
+ register: nova_compute_result
+
+- name: Add new instances groups and variables
+ add_host:
+ hostname: '{{ item.item }}'
+ ansible_ssh_host: '{{ item.public_ip }}'
+ ansible_ssh_user: "{{ deployment_vars[deployment_type].ssh_user }}"
+ ansible_sudo: "{{ deployment_vars[deployment_type].sudo }}"
+ groups: 'tag_env_{{ cluster }}, tag_host-type_{{ type }}, tag_env-host-type_{{ cluster }}-openshift-{{ type }}'
+ with_items: nova_compute_result.results
+
+- name: Wait for ssh
+ wait_for:
+ host: '{{ item.public_ip }}'
+ port: 22
+ with_items: nova_compute_result.results
+
+- name: Wait for user setup
+ command: 'ssh -o StrictHostKeyChecking=no -o PasswordAuthentication=no -o ConnectTimeout=10 -o UserKnownHostsFile=/dev/null {{ hostvars[item.item].ansible_ssh_user }}@{{ item.public_ip }} echo {{ hostvars[item.item].ansible_ssh_user }} user is setup'
+ register: result
+ until: result.rc == 0
+ retries: 30
+ delay: 1
+ with_items: nova_compute_result.results
diff --git a/playbooks/openstack/openshift-cluster/terminate.yml b/playbooks/openstack/openshift-cluster/terminate.yml
new file mode 100644
index 000000000..2f05f0992
--- /dev/null
+++ b/playbooks/openstack/openshift-cluster/terminate.yml
@@ -0,0 +1,43 @@
+- name: Terminate instance(s)
+ hosts: localhost
+ connection: local
+ gather_facts: no
+ vars_files:
+ - vars.yml
+ tasks:
+ - set_fact: cluster_group=tag_env_{{ cluster_id }}
+ - add_host:
+ name: "{{ item }}"
+ groups: oo_hosts_to_terminate
+ ansible_ssh_user: "{{ deployment_vars[deployment_type].ssh_user }}"
+ ansible_sudo: "{{ deployment_vars[deployment_type].sudo }}"
+ with_items: groups[cluster_group] | default([])
+
+- hosts: oo_hosts_to_terminate
+
+- hosts: localhost
+ connection: local
+ gather_facts: no
+ vars_files:
+ - vars.yml
+ tasks:
+ - name: Retrieve the floating IPs
+ shell: "neutron floatingip-list | awk '/{{ hostvars[item].ansible_default_ipv4.address }}/ {print $2}'"
+ with_items: groups['oo_hosts_to_terminate'] | default([])
+ register: floating_ips_to_delete
+
+ - name: Terminate instance(s)
+ nova_compute:
+ name: "{{ hostvars[item].os_name }}"
+ state: absent
+ with_items: groups['oo_hosts_to_terminate'] | default([])
+
+ - name: Delete floating IPs
+ command: "neutron floatingip-delete {{ item.stdout }}"
+ with_items: floating_ips_to_delete.results | default([])
+
+ - name: Destroy the network
+ command: "heat stack-delete {{ openstack_network_prefix }}-stack"
+ register: stack_delete_result
+ changed_when: stack_delete_result.rc == 0
+ failed_when: stack_delete_result.rc != 0 and 'could not be found' not in stack_delete_result.stdout
diff --git a/playbooks/openstack/openshift-cluster/update.yml b/playbooks/openstack/openshift-cluster/update.yml
new file mode 100644
index 000000000..5e7ab4e58
--- /dev/null
+++ b/playbooks/openstack/openshift-cluster/update.yml
@@ -0,0 +1,18 @@
+---
+- name: Populate oo_hosts_to_update group
+ hosts: localhost
+ gather_facts: no
+ vars_files:
+ - vars.yml
+ tasks:
+ - name: Evaluate oo_hosts_to_update
+ add_host:
+ name: "{{ item }}"
+ groups: oo_hosts_to_update
+ ansible_ssh_user: "{{ deployment_vars[deployment_type].ssh_user }}"
+ ansible_sudo: "{{ deployment_vars[deployment_type].sudo }}"
+ with_items: groups["tag_env-host-type_{{ cluster_id }}-openshift-master"] | union(groups["tag_env-host-type_{{ cluster_id }}-openshift-node"]) | default([])
+
+- include: ../../common/openshift-cluster/update_repos_and_packages.yml
+
+- include: config.yml
diff --git a/playbooks/openstack/openshift-cluster/vars.yml b/playbooks/openstack/openshift-cluster/vars.yml
new file mode 100644
index 000000000..c754f19fc
--- /dev/null
+++ b/playbooks/openstack/openshift-cluster/vars.yml
@@ -0,0 +1,39 @@
+---
+openstack_infra_heat_stack: "{{ opt_infra_heat_stack | default('files/heat_stack.yml') }}"
+openstack_network_prefix: "{{ opt_network_prefix | default('openshift-ansible-'+cluster_id) }}"
+openstack_network_cidr: "{{ opt_net_cidr | default('192.168.' + ( ( 1048576 | random % 256 ) | string() ) + '.0/24') }}"
+openstack_network_external_net: "{{ opt_external_net | default('external') }}"
+openstack_floating_ip_pools: "{{ opt_floating_ip_pools | default('external') | oo_split() }}"
+openstack_network_dns: "{{ opt_dns | default('8.8.8.8,8.8.4.4') | oo_split() }}"
+openstack_ssh_keypair: "{{ opt_keypair | default(lookup('env', 'LOGNAME')+'_key') }}"
+openstack_ssh_public_key: "{{ lookup('file', opt_public_key | default('~/.ssh/id_rsa.pub')) }}"
+openstack_ssh_access_from: "{{ opt_ssh_from | default('0.0.0.0/0') }}"
+openstack_flavor:
+ master:
+ ram: "{{ opt_master_flavor_ram | default(2048) }}"
+ id: "{{ opt_master_flavor_id | default() }}"
+ include: "{{ opt_master_flavor_include | default() }}"
+ node:
+ ram: "{{ opt_node_flavor_ram | default(4096) }}"
+ id: "{{ opt_node_flavor_id | default() }}"
+ include: "{{ opt_node_flavor_include | default() }}"
+
+deployment_vars:
+ origin:
+ image:
+ name: "{{ opt_image_name | default('centos-70-raw') }}"
+ id:
+ ssh_user: openshift
+ sudo: yes
+ online:
+ image:
+ name:
+ id:
+ ssh_user: root
+ sudo: no
+ enterprise:
+ image:
+ name: "{{ opt_image_name | default('centos-70-raw') }}"
+ id:
+ ssh_user: openshift
+ sudo: yes