This repository was archived by the owner on Oct 17, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 9 files changed +71
-30
lines changed
Expand file tree Collapse file tree 9 files changed +71
-30
lines changed Original file line number Diff line number Diff line change @@ -17,11 +17,26 @@ openshift_clusterroles:
1717# List of projects and rolebindings to create
1818openshift_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
2222openshift_localstorage_basedir : /volumes/local-storage
2323openshift_localstorage_num_volumes : 100
2424openshift_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.
2731openshift_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 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
Original file line number Diff line number Diff line change 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 :
Original file line number Diff line number Diff line change 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"
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 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
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 22apiVersion: v1
33kind: PersistentVolume
44metadata:
5- name: local-{{ inventory_hostname }}-<name >
5+ name: local-{{ item }}-<name >
66spec:
77 capacity:
88 storage: {{ openshift_localstorage_capacity }}
1919 - key: kubernetes.io/hostname
2020 operator: In
2121 values:
22- - {{ inventory_hostname }}
22+ - {{ item }}
You can’t perform that action at this time.
0 commit comments