File tree 9 files changed +71
-30
lines changed
9 files changed +71
-30
lines changed Original file line number Diff line number Diff line change @@ -17,11 +17,26 @@ openshift_clusterroles:
17
17
# List of projects and rolebindings to create
18
18
openshift_projects : []
19
19
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
22
22
openshift_localstorage_basedir : /volumes/local-storage
23
23
openshift_localstorage_num_volumes : 100
24
24
openshift_localstorage_capacity : 50Gi
25
25
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
+
26
30
# Set up custom volume paths like /volumes/hosted_volumes, with proper SELinux labelling.
27
31
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
+
Original file line number Diff line number Diff line change 11
11
file :
12
12
state : directory
13
13
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
Original file line number Diff line number Diff line change 9
9
- name : Install repositories for OpenShift master
10
10
package :
11
11
name :
12
- # TODO: workaround needed until Ansible version and origin repos sorted out.
13
- # https://github.com/openshift/openshift-ansible/issues/10445
14
12
- centos-release-ansible26
15
- - centos-release-openshift-origin{{ openshift_version.replace('.', '') }}
16
13
17
14
- name : Install dependencies for OpenShift master
18
15
package :
Original file line number Diff line number Diff line change 17
17
setype : container_file_t
18
18
loop : " {{ openshift_localstorage_custom_dirs }}"
19
19
20
- - name : Template local-storage PV template
21
- template :
22
- src : pv.yaml.j2
23
- dest : " {{ openshift_ansible_tmp }}/pv.yaml"
24
-
25
20
- name : Create volumes
26
21
shell : echo {0..{{ openshift_localstorage_num_volumes }}} | xargs -d ' ' -n 1 -I '{}' mkdir -p '{{ openshift_localstorage_basedir }}/vol{}'
27
22
args :
28
23
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"
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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"
Original file line number Diff line number Diff line change 1
1
---
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
7
14
when : openshift_localstorage_enabled
15
+
16
+ - import_tasks : node.yml
17
+ when : not openshift_is_ansible_master
Original file line number Diff line number Diff line change
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 }}"'
Original file line number Diff line number Diff line change 2
2
apiVersion: v1
3
3
kind: PersistentVolume
4
4
metadata:
5
- name: local-{{ inventory_hostname }}-<name >
5
+ name: local-{{ item }}-<name >
6
6
spec:
7
7
capacity:
8
8
storage: {{ openshift_localstorage_capacity }}
19
19
- key: kubernetes.io/hostname
20
20
operator: In
21
21
values:
22
- - {{ inventory_hostname }}
22
+ - {{ item }}
You can’t perform that action at this time.
0 commit comments