Skip to content

Commit d14dec6

Browse files
committed
Cluster deployment
1 parent efab141 commit d14dec6

9 files changed

+71
-30
lines changed

Diff for: defaults/main.yml

+17-2
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,26 @@ openshift_clusterroles:
1717
# List of projects and rolebindings to create
1818
openshift_projects: []
1919

20-
# Local storage config (this creates the additional objects beyond inventory config)
21-
openshift_localstorage_enabled: yes
20+
# Local storage creation (this creates the additional objects beyond inventory config)
21+
openshift_localstorage_enabled: yes # make sure to modify openshift_localstorage_hosts as well
2222
openshift_localstorage_basedir: /volumes/local-storage
2323
openshift_localstorage_num_volumes: 100
2424
openshift_localstorage_capacity: 50Gi
2525

26+
# List of hosts to create PV objects for.
27+
# Set to None if local storage is disabled.
28+
openshift_localstorage_hosts: ["{{ inventory_hostname }}"]
29+
2630
# Set up custom volume paths like /volumes/hosted_volumes, with proper SELinux labelling.
2731
openshift_localstorage_custom_dirs: []
32+
33+
# Distinguish between nodes and Ansible masters
34+
openshift_is_ansible_master: yes
35+
36+
# Deploy SSH key for master host
37+
# TODO: collect the public key automatically - two step procedure for now
38+
openshift_ssh_public_key: 'ssh-rsa ...'
39+
40+
# IP or FQDN of the Ansible master (used to restrict the SSH key)
41+
openshift_ssh_from: 0.0.0.0/0
42+

Diff for: tasks/ansible.yml

+5
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,8 @@
1111
file:
1212
state: directory
1313
path: "{{ openshift_ansible_tmp }}"
14+
15+
- name: Generate SSH key
16+
command: ssh-keygen -b 2048 -t rsa -f /root/.ssh/id_rsa -q -N ""
17+
args:
18+
creates: /root/.ssh/id_rsa

Diff for: tasks/dependencies.yml

-3
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@
99
- name: Install repositories for OpenShift master
1010
package:
1111
name:
12-
# TODO: workaround needed until Ansible version and origin repos sorted out.
13-
# https://github.com/openshift/openshift-ansible/issues/10445
1412
- centos-release-ansible26
15-
- centos-release-openshift-origin{{ openshift_version.replace('.', '') }}
1613

1714
- name: Install dependencies for OpenShift master
1815
package:

Diff for: tasks/localstorage.yml renamed to tasks/localstorage-dirs.yml

-18
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,7 @@
1717
setype: container_file_t
1818
loop: "{{ openshift_localstorage_custom_dirs }}"
1919

20-
- name: Template local-storage PV template
21-
template:
22-
src: pv.yaml.j2
23-
dest: "{{ openshift_ansible_tmp }}/pv.yaml"
24-
2520
- name: Create volumes
2621
shell: echo {0..{{ openshift_localstorage_num_volumes }}} | xargs -d ' ' -n 1 -I '{}' mkdir -p '{{ openshift_localstorage_basedir }}/vol{}'
2722
args:
2823
creates: "{{ openshift_localstorage_basedir }}/vol{{ openshift_localstorage_num_volumes - 1}}"
29-
30-
- name: Create PVs
31-
shell: echo {0..{{ openshift_localstorage_num_volumes }}} | xargs -d ' ' -n 1 -I '{}' sed 's/<name>/vol{}/' {{ openshift_ansible_tmp }}/pv.yaml | oc create -f -
32-
# will fail when volumes already exist
33-
failed_when: no
34-
35-
- name: Template local-storage storage class
36-
template:
37-
src: storage-class.yaml.j2
38-
dest: "{{ openshift_ansible_tmp }}/storage-class.yaml"
39-
40-
- name: Apply local-storage storage class
41-
shell: oc apply -f "{{ openshift_ansible_tmp }}/storage-class.yaml"

Diff for: tasks/localstorage-master-pv.yaml.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
3+
# TODO: simplify this by rendering a single List object
4+
5+
- name: Template local-storage PV template for {{ item }}
6+
template:
7+
src: pv.yaml.j2
8+
dest: "{{ openshift_ansible_tmp }}/pv.yaml"
9+
10+
- name: Create PVs for {{ item }}
11+
shell: echo {0..{{ openshift_localstorage_num_volumes }}} | xargs -d ' ' -n 1 -I '{}' sed 's/<name>/vol{}/' {{ openshift_ansible_tmp }}/pv.yaml | oc create -f -
12+
# will fail when volumes already exist
13+
failed_when: no

Diff for: tasks/localstorage-master.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
3+
- include_tasks: localstorage-master-pv.yaml
4+
loop: "{{ openshift_localstorage_hosts }}"
5+
6+
- name: Template local-storage storage class
7+
template:
8+
src: storage-class.yaml.j2
9+
dest: "{{ openshift_ansible_tmp }}/storage-class.yaml"
10+
11+
- name: Apply local-storage storage class
12+
shell: oc apply -f "{{ openshift_ansible_tmp }}/storage-class.yaml"

Diff for: tasks/main.yml

+15-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
---
2-
- import_tasks: dependencies.yml
3-
- import_tasks: ansible.yml
4-
# TODO: run Ansible deployment on the host and wait for it to complete
5-
- import_tasks: users.yml
6-
- import_tasks: localstorage.yml
2+
3+
- block:
4+
- import_tasks: dependencies.yml
5+
- import_tasks: ansible.yml
6+
# TODO: run Ansible deployment on the host and wait for it to complete
7+
- import_tasks: users.yml
8+
- import_tasks: localstorage-master.yml
9+
when: openshift_localstorage_hosts
10+
11+
when: openshift_is_ansible_master
12+
13+
- import_tasks: localstorage-dirs.yml
714
when: openshift_localstorage_enabled
15+
16+
- import_tasks: node.yml
17+
when: not openshift_is_ansible_master

Diff for: tasks/node.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
3+
- name: SSH keys
4+
authorized_key:
5+
key: "{{ openshift_ssh_public_key }}"
6+
user: root
7+
key_options: 'from="{{ openshift_ssh_from }}"'

Diff for: templates/pv.yaml.j2

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
apiVersion: v1
33
kind: PersistentVolume
44
metadata:
5-
name: local-{{ inventory_hostname }}-<name>
5+
name: local-{{ item }}-<name>
66
spec:
77
capacity:
88
storage: {{ openshift_localstorage_capacity }}
@@ -19,4 +19,4 @@ spec:
1919
- key: kubernetes.io/hostname
2020
operator: In
2121
values:
22-
- {{ inventory_hostname }}
22+
- {{ item }}

0 commit comments

Comments
 (0)