]> git.apps.os.sepia.ceph.com Git - ceph-cm-ansible.git/commitdiff
Add post-install trigger to run ansible
authorZack Cerza <zack@redhat.com>
Mon, 4 May 2015 16:51:17 +0000 (10:51 -0600)
committerZack Cerza <zack@redhat.com>
Tue, 5 May 2015 16:03:02 +0000 (10:03 -0600)
Signed-off-by: Zack Cerza <zack@redhat.com>
roles/cobbler/defaults/main.yml
roles/cobbler/tasks/upload_templates.yml
roles/cobbler/templates/triggers/install/post/cephlab_ansible.sh [new file with mode: 0644]

index e60d8325a34d229dd7db2d76a8f916ddc352e26c..d03871b54f951ade1453a610950344c4f35ce74b 100644 (file)
@@ -12,6 +12,9 @@ snippets:
 scripts:
   - cephlab_preseed_late
 
+triggers:
+  - install/post/cephlab_ansible.sh
+
 ssh_keys: []
 
 ansible_user: ''
index 66a83f06b8ab29daff2d50480e1ee281f4619768..6f37e4599e7ed016190d4287ed9871125be7d360 100644 (file)
   with_items: scripts
   tags:
     - scripts
+
+- name: Upload triggers.
+  template:
+    src: "triggers/{{ item }}"
+    dest: "/var/lib/cobbler/triggers/{{ item }}"
+    owner: root
+    group: root
+    mode: 0744
+  with_items: triggers
+  tags:
+    - triggers
diff --git a/roles/cobbler/templates/triggers/install/post/cephlab_ansible.sh b/roles/cobbler/templates/triggers/install/post/cephlab_ansible.sh
new file mode 100644 (file)
index 0000000..40ed514
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/bash
+## {{ ansible_managed }}
+set -ex
+name=$2
+export USER=root
+export HOME=/root
+ANSIBLE_CM_PATH=/root/ceph-cm-ansible
+
+# Bail if the ssh port isn't open, as will be the case when this is run 
+# while the installer is still running. When this is triggered by 
+# /etc/rc.local after a reboot, the port will be open and we'll continue
+nc -vz $name 22
+
+mkdir -p /var/log/ansible
+
+# Tell ansible to create users and populate authorized_keys
+pushd $ANSIBLE_CM_PATH
+ANSIBLE_SSH_PIPELINING=1 ansible-playbook testnodes.yml -vv --limit $name* --tags user,pubkeys 2>&1 | tee /var/log/ansible/$name.log
+popd