Skip to content

Instantly share code, notes, and snippets.

@tomster
Last active July 5, 2018 09:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tomster/5cfb45030e06ffb7b91a to your computer and use it in GitHub Desktop.
Save tomster/5cfb45030e06ffb7b91a to your computer and use it in GitHub Desktop.
Ansible playbook to build nix on FreeBSD
---
- hosts:
- nixhost
tasks:
- name: Ensure dependency packages are installed
pkgng:
name: "{{item}}"
state: present
with_items:
- sudo
- curl
- perl5
- openssl
- bash
- pkgconf
- sqlite3
- gmake
- autoconf
- automake
- git
- libxslt
- docbook-xsl-ns
- bison
- p5-DBI
- p5-DBD-SQLite
- p5-WWW-Curl
- gtar
- name: fetch nix sources
git:
repo: "https://github.com/manueljacob/nix"
version: "freebsd-build-fixes"
dest: "/home/nixbuild/nix"
accept_hostkey: yes
sudo_user: nixbuild
- name: bootstrap checkout
command: bash bootstrap.sh
args:
chdir: "/home/nixbuild/nix"
creates: "/home/nixbuild/nix/configure"
sudo_user: nixbuild
- name: configure checkout
command: bash configure
args:
chdir: "/home/nixbuild/nix"
creates: "/home/nixbuild/nix/config.status"
sudo_user: nixbuild
- name: build nix
command: gmake
args:
chdir: "/home/nixbuild/nix"
creates: "/home/nixbuild/nix/scripts/nix-build"
sudo_user: nixbuild
- name: install nix
command: gmake install
args:
chdir: "/home/nixbuild/nix"
creates: "/usr/local/bin/nix-build"
- name: create group
group:
name: nixbld
- name: create nixbld users
user:
name: "{{item}}"
groups: nixbld
with_items:
- nxbld1
- nxbld2
tags: foo
@ysangkok
Copy link

This is what I get when I try to run this:

$ ansible-playbook -c local ./nixbuild.yml -vvvv
No config file found; using defaults
 [WARNING]: provided hosts list is empty, only localhost is available

[DEPRECATION WARNING]: Instead of sudo/sudo_user, use become/become_user and make sure become_method is 'sudo' (default). This feature will be removed in a 
future release. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
1 plays in ./nixbuild.yml
Loaded callback default of type stdout, v2.0

PLAY ***************************************************************************

TASK [setup] *******************************************************************
ESTABLISH LOCAL CONNECTION FOR USER: janus
127.0.0.1 EXEC (umask 22 && mkdir -p "$(echo $HOME/.ansible/tmp/ansible-tmp-1446079308.87-42359250863945)" && echo "$(echo $HOME/.ansible/tmp/ansible-tmp-1446079308.87-42359250863945)")
127.0.0.1 PUT /tmp/tmpLs07gt TO /home/janus/.ansible/tmp/ansible-tmp-1446079308.87-42359250863945/setup
127.0.0.1 EXEC LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/local/bin/python /home/janus/.ansible/tmp/ansible-tmp-1446079308.87-42359250863945/setup; rm -rf "/home/janus/.ansible/tmp/ansible-tmp-1446079308.87-42359250863945/" > /dev/null 2>&1
ok: [localhost]

TASK [Ensure dependency packages are installed] ********************************
task path: /usr/home/janus/nixbuild.yml:6
ESTABLISH LOCAL CONNECTION FOR USER: janus
127.0.0.1 EXEC (umask 22 && mkdir -p "$(echo $HOME/.ansible/tmp/ansible-tmp-1446079311.43-37858262415666)" && echo "$(echo $HOME/.ansible/tmp/ansible-tmp-1446079311.43-37858262415666)")
127.0.0.1 PUT /tmp/tmpqoKt6M TO /home/janus/.ansible/tmp/ansible-tmp-1446079311.43-37858262415666/pkgng
127.0.0.1 EXEC LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/local/bin/python /home/janus/.ansible/tmp/ansible-tmp-1446079311.43-37858262415666/pkgng; rm -rf "/home/janus/.ansible/tmp/ansible-tmp-1446079311.43-37858262415666/" > /dev/null 2>&1
failed: [localhost] => (item=sudo,curl,perl5,openssl,bash,pkgconf,sqlite3,gmake,autoconf,automake,git,libxslt,docbook-xsl-ns,bison,p5-DBI,p5-DBD-SQLite,p5-WWW-Curl,gtar) => {"failed": true, "invocation": {"module_args": {"name": "sudo,curl,perl5,openssl,bash,pkgconf,sqlite3,gmake,autoconf,automake,git,libxslt,docbook-xsl-ns,bison,p5-DBI,p5-DBD-SQLite,p5-WWW-Curl,gtar", "state": "present"}, "module_name": "pkgng"}, "item": "sudo,curl,perl5,openssl,bash,pkgconf,sqlite3,gmake,autoconf,automake,git,libxslt,docbook-xsl-ns,bison,p5-DBI,p5-DBD-SQLite,p5-WWW-Curl,gtar", "msg": "Could not update catalogue"}

PLAY RECAP *********************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=1

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