Skip to content

Instantly share code, notes, and snippets.

@benileo
Created June 11, 2017 18:48
Show Gist options
  • Save benileo/a01126a908b654e6b25d935ab1c11ced to your computer and use it in GitHub Desktop.
Save benileo/a01126a908b654e6b25d935ab1c11ced to your computer and use it in GitHub Desktop.
Ansible, cloud init has completed successfully
- name: Ensuring that cloud init has complete.
hosts: "Enter your hosts here"
tasks:
- stat:
path: /var/lib/cloud/instance/boot-finished
register: st
- fail:
msg: "/var/lib/cloud/instance/boot-finished does not exist; Cloud init has not complete"
when: st.stat.exists == False
- shell:
cmd: >
cat /var/lib/cloud/data/result.json | python -c "import sys,json; sys.exit(1) if json.loads(sys.stdin.read())['v1']['errors'] else sys.exit(0)"
become: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment