Test project for configuring a workstations by bootstrapping an Ansible controller on the executing host
ATTENTION
Executing these tests will make changes to your system including:
-
Ensuring for a ~/projects directory
-
Ensuring for a clone of this project in ~/projects/workstation
-
Bootstrapping a Python virtualenv based Ansible Controller with:
- Molecule 2.19.0
- Ansible
-
Install all Ansible roles in the projects requirements.yml file
-
Execute any roles in the projects
site.yml
file. - You can avoid this last step by runninginit_ubuntu.sh
instead of theinit-n-run_ubuntu.sh
script at the end of the curl command
Examples:
cd
rm -rf ~/projects/workstation
Rerun from the start:
NOTE: If things are not progressing, press Enter once, you may be prompted for your sudo password.
sudo ls -al # force prompt for sudo a password
curl -k -L https://raw.githubusercontent.com/cjsteel/ansible-project-workstation/master/init-n-run_ubuntu.sh | sudo bash
Manual local testing
sudo ./init-n-run_ubuntu.sh
- run against localhost
You can add new Ansible roles by adding them to the projects requirements.yml and site.yml files
Currently actuates the installation of these fine ansible role(s).
# Install with: `ansible-galaxy install -r requirements.yml`
# from GitHub, overriding the name and specifying a specific tag
- src: https://github.com/geerlingguy/ansible-role-clamav.git
version: 1.3.1
name: geerlingguy.clamav
---
- hosts: "{{ host | default('localhost') }}"
become: True
roles:
- geerlingguy.clamav
You may also want to adjust the included ansible.cfg file
https://docs.ansible.com/ansible/2.4/intro_configuration.html#roles-path https://docs.ansible.com/ansible/latest/reference_appendices/config.html
Current contents:
[defaults]
inventory=./inventory
roles_path=./roles
If you want to add a new role to your local install for testing or development you can do something like the following:
cd roles
molecule init role --role-name ansible-role-something
cd ansible-role-something
molecule init scenario -s lxd -d lxd --role-name ansible-role-something
test it using bionic VM
nano molecule/lxd/molecule.yml
Content example:
---
dependency:
name: galaxy
driver:
name: lxd
lint:
name: yamllint
platforms:
- name: something-bionic
source:
type: image
mode: pull
protocol: simplestreams
alias: ubuntu/bionic/amd64
architecture: x86_64
config:
limits.cpu: '4'
devices:
kvm:
path: /dev/kvm
type: unix-char
profiles:
- default
force_stop: False
provisioner:
name: ansible
lint:
name: ansible-lint
scenario:
name: lxd
verifier:
name: testinfra
lint:
name: flake8
molecule --debug create -s lxd
Ensure that container is actually 18.04, some glitches in
lxc file pull something-bionic/etc/lsb-release .
cat lsb-release
rm lsb-release
Desired output
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.2 LTS"
If you want to add additional roles from other developers
Using ansible-galaxy while in the projects directory should install them to ~/projects/workstation/roles
due to the customizations in (the included ansible.cfg file.
ansible-galaxy install geerlingguy.clamav
Ensuring that the included testing is working (default docker scenario):
cd ~/projects/workstation/roles
cd geerlingguy.clamav
molecule init scenario -s default -d docker --role-name=geerlingguy.clamav
molecule init scenario -s lxd -d lxd --role-name=geerlingguy.clamav