Created
July 9, 2017 20:55
-
-
Save jasperla/6ba7512b410dfb479788047b028873f7 to your computer and use it in GitHub Desktop.
Bootstrapping Ansible on SmartOS headnode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
# Playbook to bootstrap a SmartOS headnode for use with Ansible | |
- name: bootstrap a SmartOS headnode | |
hosts: smartos-headnode | |
gather_facts: no | |
vars: | |
pkgsrc_rel: 2017Q1 | |
bootstrap_tar: bootstrap-{{ pkgsrc_rel }}-tools.tar.gz | |
bootstrap_sha1: a39d8dce904c2d0afb3cb570c671490153a71f15 | |
ansible_ssh_pubkey: 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDCXRiC3PzMKMCI7X1s2l6amMfN0avqlyRasd1VU0pLiROwu6fyyA1HAkngnu68dXfReAx2/CVYOxXDAQUOyXAgR4wDPOd1NT7NQWFawr0xN8RdgD0l8BQRbJfz61KvBUyFC7brsg5liIbAsqDwB35s3Nchq8yEJj6cv7CPngP/5JMS6wUUT6CFtWimqsxRVGuUNWRlhGeU+CO62EoQXutndhbjbQKGXieKjO3ZLSKsXkDfrfwSwyoc/6HMZP4EJqKWVYufzq3zAxGargDm0a7RRincC1McvbwH/YEx9CDekCzoW1aaATJlvqooX4HzdqwjSduUQD/2rfHpL8576jYZsZWOAseJgDJAN5LvFiVTdFtC8el9BdT7J5EpKb8t7zlMRJ12qso5IJCabzcqTtpPhzu/JdP5wLDPyExAZI94vO8q0CLbMvkMYiS7hpgVHshmxsTiyOzT+nxmoJwqnCIUAq8sQgM8o/Nou0lzX55zVRx3icTlhdNCLQx/62pcbvm2pVjPDGd/yf0g1fdAxH7QIth6qmerFdiXmER0VkJ0V9nDQNbPbkzLp713TXaYI2grLbs9D+SHTXOSWD3H16V4KitYdGyBS17IwRGKxdSDDlX4lQiUNZhsEoEycqfKc3KXHTdZcXwK+gwkB+jl8LVIzFz67UyMLLhnK1qeS0nrOQ==' | |
tasks: | |
- name: Create authorized_keys file if needed | |
raw: '[ -f /usbkey/config.inc/authorized_keys ] || (mkdir -p /usbkey/config.inc/ && touch /usbkey/config.inc/authorized_keys)' | |
- name: Install SSH public key | |
raw: echo {{ ansible_ssh_pubkey }} >> /usbkey/config.inc/authorized_keys | |
- name: Download bootstrap tarball | |
raw: cd /tmp && curl -kO https://pkgsrc.joyent.com/packages/SmartOS/bootstrap/{{ bootstrap_tar }} | |
- name: Verify SHA1 sum | |
raw: /bin/digest -a sha1 /tmp/{{ bootstrap_tar }} | |
register: bootstrap_cksum | |
- fail: | |
msg: checksum mismatch for {{ bootstrap_tar }} | |
when: bootstrap_cksum.stdout_lines[0] != bootstrap_sha1 | |
- name: Install pkgsrc bootstrap {{ pkgsrc_rel }} | |
raw: tar -zxpf /tmp/{{ bootstrap_tar }} -C / | |
- name: Create local pkgin database | |
raw: /opt/tools/bin/pkgin update | |
- name: Install python | |
raw: /opt/tools/bin/pkgin -y install python27 | |
- name: Verify installation | |
raw: /opt/tools/bin/python2.7 --version | |
register: python_output | |
ignore_errors: yes | |
- fail: | |
msg: "Python does not appear to have been installed: {{ python_output.stdout }}" | |
when: '"Python" not in python_output.stdout' | |
- name: Cleanup {{ bootstrap_tar }} | |
raw: rm -f /tmp/{{ bootstrap_tar }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment