Skip to content

Instantly share code, notes, and snippets.

@jlgaddis
Created August 2, 2016 17:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jlgaddis/b923ee7deeca600febd988889de5871e to your computer and use it in GitHub Desktop.
Save jlgaddis/b923ee7deeca600febd988889de5871e to your computer and use it in GitHub Desktop.
Bootstrap OpenBSD so it can be managed by Ansible
#!/usr/bin/env sh
#
# This script can be executed to bootstrap a clean OpenBSD installation
# so that it can be managed via Ansible.
#
# Enter the root password when prompted (twice)
#
# NB: Assumes $TARGET_HOST has already been added to inventory and
# appropriate groups, and that variables are set as necessary
# (e.g. ansible_become_method, ansible_python_interpreter, etc.)
#
ansible $TARGET_HOST -m raw -b -K -a "echo 'permit nopass bofh as root' > /etc/doas.conf" -e "ansible_become_method=su"
ansible $TARGET_HOST -m raw -b -K -a "echo 'installpath = mirrors.gigenet.com' > /etc/pkg.conf" -e "ansible_become_method=su"
ansible $TARGET_HOST -m raw -b -a "pkg_add -z python-2"
# To test success, run "ansible $TARGET_HOST -m setup"
@jlgaddis
Copy link
Author

jlgaddis commented Aug 6, 2016

Alternatively, log in to the OpenBSD system, either locally or via SSH, and execute the following commands (as root):

# echo 'permit nopass bofh as root' > /etc/doas.conf
# echo 'installpath = mirrors.gigenet.com' > /etc/pkg.conf
# pkg_add -z python-2

The system can now be managed via Ansible.

@pbartruff
Copy link

pkg.conf is deprecated. You can use /etc/installurl now. Also the url only has to end at OpenBSD the version and package "directory" are appended to the uri eg:
tasks:

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