Skip to content

Instantly share code, notes, and snippets.

@illenseer
Created August 30, 2013 14:21
Show Gist options
  • Save illenseer/6390361 to your computer and use it in GitHub Desktop.
Save illenseer/6390361 to your computer and use it in GitHub Desktop.
Playbook to get all prerequest for ansible installed on FreeBSD.
---
- hosts: freebsd
gather_facts: false
user: root
tasks:
- name: install pkgng
raw: "pkg_info | grep -v 'pkg-' > /dev/null ; if $? then pkg_add -r pkg; pkg2ng; echo 'WITH_PKGNG=yes' >> /etc/make.conf; echo 'packagesite: <your_pkg_mirror>' >> /usr/local/etc/pkg.conf; pkg update; endif"
- name: install python27
raw: pkg install -y python27
- name: add ansible ssh-key
authorized_key: user=root key="{{ item }}"
with_file:
- ../ssh_keys/ansible.pub
@tomster
Copy link

tomster commented Sep 1, 2013

FWIW it's not working for me:

PLAY [jailhost] *************************************************************** 

TASK: [install pkgng] ********************************************************* 
<10.0.1.180> ESTABLISH CONNECTION FOR USER: tomster
<10.0.1.180> EXEC ['ssh', '-tt', '-q', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/Users/tomster/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'Port=22', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'ConnectTimeout=10', '10.0.1.180', u'/bin/sh -c \'sudo -k && sudo -H -S -p "[sudo via ansible, key=ktivepxevjqvjuzeqwsetgprmhglvedx] password: " -u root $SHELL -c \'"\'"\'pkg_info | grep -v \'"\'"\'"\'"\'"\'"\'"\'"\'pkg-\'"\'"\'"\'"\'"\'"\'"\'"\' > /dev/null ; if $? then pkg_add -r pkg; pkg2ng; echo \'"\'"\'"\'"\'"\'"\'"\'"\'WITH_PKGNG=yes\'"\'"\'"\'"\'"\'"\'"\'"\' >> /etc/make.conf; pkg update; endif\'"\'"\'\'']
failed: [10.0.1.180] => {"rc": 2}
stdout: Syntax error: end of file unexpected (expecting "then")


FATAL: all hosts have already failed -- aborting

PLAY RECAP ******************************************************************** 
           to retry, use: --limit @/Users/tomster/bootstrap.retry

10.0.1.180                 : ok=0    changed=0    unreachable=0    failed=1   

@tomster
Copy link

tomster commented Nov 21, 2013

FWIW here's the working version that i eventually ended up with https://gist.github.com/tomster/7585211

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment