Ansible role to bootstrap a fresh system to accept subsequent Ansible plays.
This is a minimal role that installs a (minimal) version of python
,
to ensure that subsequent plays may use Ansible's typical python
-based functionality.
This role requires (on your control node)
- a minimal version (> 1.2) of Ansible
None.
-
bootstrap_python_verison
(default:'python3'
)Select the version of python to install. Assumes
python3
, but could set topython
if you need old-school. Further assumes that you have your ansible configuration for interpreter discovery set, or you are happy with the defaults. -
bootstrap_python_auto_fallback
(default:true
)If true, auto-fallback to just
python[2]
on older distributions where, there is no trivial (viaapt|yum|pkg
) installation of minimal version of python required by ansible. This currently affects on the following distributions, where this role will installpython
(akapython2
) instead:- Centos 6
- Centos 7
- Debian Jessie (Debian 8)
- Ubuntu Trusty Tahr (Ubuntu 14.04)
-
bootstrap_gather_facts
(default:'all'
)Specifies the subset of facts to be gathered by the
setup
module after the bootstrap installation of python. May be a single item (string) or a list of string values. See documentation for thegather_subset
parameter of thesetup
module for a complete list of possible values.Defaults to
'all'
, which is thesetup
module default.May be set to
false
(or an empty list or an empty string) to disable the gathering of facts post bootstrap.
There is very little to this role, however, because it's primary task is to install python
, any playbook that makes use of it must disable the gathering of facts before it runs; for example:
- hosts: all
gather_facts: false
become: true
roles:
- eengstrom.bootstrap
After bootstrap, the module will attempt to re-gather facts not yet in Ansible's brain, per the variable bootstrap_gather_facts
.
Because this playbook is intended to be run on a fresh system, typically you will also need to accept or cache ssh keys for the new systems. For that, see my eengstrom.known_hosts
role.
Testing of this role uses molecule
and it's docker driver. To test, I use pipenv
for a local python environment. One-liner to test:
pipenv install --dev && pipenv run molecule test
CAVEAT: I do not have testing for FreeBSD, largely because using docker on Linux to spin up FreeBSD containers is not really easy. PRs welcome.
- Eric Engstrom
... with thanks to Willem de Groot, who wrote the GitHub Gist upon which this is based.