Added seed code for caas-cpupooler.
[ta/caas-cpupooler.git] / ansible / roles / cpupooler / tasks / create_cpu_pools.yaml
diff --git a/ansible/roles/cpupooler/tasks/create_cpu_pools.yaml b/ansible/roles/cpupooler/tasks/create_cpu_pools.yaml
new file mode 100644 (file)
index 0000000..e5af187
--- /dev/null
@@ -0,0 +1,41 @@
+---
+# Copyright 2019 Nokia
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+  - name: collect facts from all hosts
+    setup:
+      gather_subset: min
+    delegate_to: "{{ item }}"
+    delegate_facts: true
+    with_items: "{{ groups['all'] }}"
+
+  - name: make cpu pooler configs
+    set_fact:
+      cpu_poolconfigs: "{{ lookup('template', 'ncir_cpu_pooler_config.yaml.j2') | from_yaml }}"
+
+  - name: template cpu pooler fact file
+    copy:
+      content: "{{ cpu_poolconfigs | to_nice_json }}"
+      dest: "/etc/ansible/facts.d/ncir_cpu_pooler_config.fact"
+    become: true
+    become_user: root
+    register: cpu_pooler_template
+
+  - name: sync to avoid IO issues
+    command: "sync"
+
+  - name: reload facts
+    setup:
+      gather_subset: min
+    when: cpu_pooler_template | changed