@@ -19,9 +19,9 @@ Role Variables
19
19
20
20
` openhpc_packages ` : additional OpenHPC packages to install
21
21
22
- ` openhpc_enable ` :
22
+ ` openhpc_enable ` :
23
23
* ` control ` : whether to enable control host
24
- * ` batch ` : whether to enable compute nodes
24
+ * ` batch ` : whether to enable compute nodes
25
25
* ` runtime ` : whether to enable OpenHPC runtime
26
26
* ` drain ` : whether to drain a compute nodes
27
27
* ` resume ` : whether to resume a compute nodes
@@ -38,6 +38,9 @@ And an Ansible inventory as this:
38
38
openhpc-compute-0 ansible_host=10.60.253.31 ansible_user=centos
39
39
openhpc-compute-1 ansible_host=10.60.253.32 ansible_user=centos
40
40
41
+ [cluster_login:children]
42
+ openhpc_login
43
+
41
44
[cluster_control:children]
42
45
openhpc_login
43
46
@@ -46,7 +49,7 @@ And an Ansible inventory as this:
46
49
47
50
Example Playbooks
48
51
----------------
49
-
52
+
50
53
To deploy, create a playbook which looks like this:
51
54
52
55
---
@@ -80,24 +83,28 @@ To drain nodes, for example, before scaling down the cluster to 6 nodes:
80
83
---
81
84
- hosts: openstack
82
85
gather_facts: false
83
-
86
+ vars:
87
+ partition: "{{ cluster_group.output_value | selectattr('group', 'equalto', item.name) | list }}"
88
+ openhpc_slurm_partitions:
89
+ - name: "compute"
90
+ flavor: "compute-A"
91
+ image: "CentOS7.5-OpenHPC"
92
+ num_nodes: 6
93
+ user: "centos"
94
+ openhpc_cluster_name: openhpc
84
95
roles:
96
+ # Our stackhpc.cluster-infra role can be invoked in `query` mode which
97
+ # looks up the state of the cluster by querying the Heat API.
85
98
- role: stackhpc.cluster-infra
86
99
cluster_name: "{{ cluster_name }}"
87
100
cluster_state: query
88
101
cluster_params:
89
102
cluster_groups: "{{ cluster_groups }}"
90
103
tasks:
104
+ # Given that the original cluster that was created had 8 nodes and the
105
+ # cluster we want to create has 6 nodes, the computed desired_state
106
+ # variable stores the list of instances to leave untouched.
91
107
- name: Count the number of compute nodes per slurm partition
92
- vars:
93
- partition: "{{ cluster_group.output_value | selectattr('group', 'equalto', item.name) | list }}"
94
- openhpc_slurm_partitions:
95
- - name: "compute"
96
- flavor: "compute-A"
97
- image: "CentOS7.5-OpenHPC"
98
- num_nodes: 6
99
- user: "centos"
100
- openhpc_cluster_name: openhpc
101
108
set_fact:
102
109
desired_state: "{{ (( partition | first).nodes | map(attribute='name') | list )[:item.num_nodes] + desired_state | default([]) }}"
103
110
when: partition | length > 0
@@ -106,9 +113,13 @@ To drain nodes, for example, before scaling down the cluster to 6 nodes:
106
113
107
114
- hosts: cluster_batch
108
115
become: yes
116
+ vars:
117
+ desired_state: "{{ hostvars['localhost']['desired_state'] | default([]) }}"
109
118
roles:
119
+ # Now, the stackhpc.openhpc role is invoked in drain/resume modes where
120
+ # the instances in desired_state are resumed if in a drained state and
121
+ # drained if in a resumed state.
110
122
- role: stackhpc.openhpc
111
- desired_state: "{{ hostvars['localhost']['desired_state'] | default([]) }}"
112
123
openhpc_slurm_control_host: "{{ groups['cluster_control'] | first }}"
113
124
openhpc_enable:
114
125
drain: "{{ inventory_hostname not in desired_state }}"
0 commit comments