Appendix: Using AnsibleΒΆ

A compute node can be configured to execute an Ansible playbook when booted. For example:

# Update the administrator's PATH, add our keys, and scan localhost keys.
export PATH=${PATH}:/opt/scyld/clusterware/git/bin
scyld-adminctl up keys=@/full/path/.ssh/id_rsa.pub
ssh-keyscan localhost >> ~/.ssh/known_hosts

# Create the git repo.
scyld-clusterctl gitrepos create name=ansible

# Clone the git repo.
git clone cwgit@localhost:ansible

# Create an Ansible playbook.
cat >ansible/HelloWorld.yaml <<EOF
---
- name: This is a hello-world example
  hosts: n*.cluster.local
  tasks:
    - name: Create a file called '/tmp/testfile.txt' with the content
      copy:
        content: hello world
        dest: /tmp/testfile.txt
EOF

# Add the Ansible playbook to the local git repo.
bash -c "\
  cd ansible; \
  git add HelloWorld.yaml; \
  git -c user.name=Test -c user.email='<test@test.test>' \
         commit --message 'Adding a test playbook' HelloWorld.yaml; \
  git push; \
"

# Install ansible into the DefaultImage.
scyld-modimg -iDefaultImage --install clusterware-ansible --upload --overwrite

# Tell node n1 to execute that playbook at boot time.
scyld-nodectl -i n1 set _ansible_pull=git:ansible/HelloWorld.yaml

# Now reboot the node and wait for it to boot to an "up" stat
scyld-nodectl -i n1 reboot
scyld-nodectl -i n1 waitfor up

# Verify that the HelloWorld.yaml executed.
scyld-nodectl -in1 exec cat /tmp/testfile.txt ; echo