Presented by
Zackary Lowery
on June 22nd, 2020 at
Leading EDJE.
Available online at https://presentations.xcjs.com/
Press your space bar or swipe to navigate down and then forward. ยป
Selectively sourced from Gruntwork's Why we use Terraform and not Chef, Puppet, Ansible, SaltStack, or CloudFormation
| Configuration Management | Provisioning |
|---|---|
| Manage existing infrastructure through software installation and configuration. | Supply new infrastructure such as servers, network routes, or other systems. |
| Trait | Types |
|---|---|
| Mutability | Mutable vs. Immutable |
| Syntax | Declarative vs. Procedural |
| Mastered | Master vs. Masterless |
| Agented | Agented vs. Agentless |
| Tool | Traits |
|---|---|
Terraform
|
Provisioning |
CloudFormation
|
Provisioning |
Chef
|
Configuration |
Puppet
|
Configuration |
SaltStack
|
Configuration |
| Host | OS | Primary Role |
|---|---|---|
| X99 |
|
Primary Client |
| USERV |
|
Personal Server |
| XCJS |
|
Personal Web Site |
| CLOUD |
|
Cloud Server |
| UDEV2 |
|
Software Development |
| MDEV |
|
Third Monitor |
| MDEV2 |
|
Software Development |
| GNUBEE |
|
NAS |
| AR4 |
|
Gaming Console |
| XPS410 |
|
Folding@home Client |
| LAKKA |
|
Emulation Gaming Console |
| K8S[0-4] |
|
Kubernetes Cluster |
| XPSM170 |
|
Retired (x86 Only) |
Facts are variables gathered from the host before Ansible begins the playbook.
all:
hosts:
ungrouped-host:
ansible_*: Override Ansible config/fact
vars:
host_var: example value
vars:
global_var: example value
children:
group:
hosts:
grouped-host:
# Each host can have its own vars/overrides.
---
- name: Install build-essential
apt:
name: build-essential
update_cache: yes
---
- name: Require the build-essential role
include_role:
name: build-essential
- name: Execute the Node.js 12 LTS install script
script: node_setup_12.x
- name: Install nodejs
apt:
name: nodejs
update_cache: yes
# ...
- name: Start the plex container
docker_compose:
build: yes
project_src: /tmp/ansible/roles/plex/files/
environment:
# Lines that begin with Jinja variables need to
# be quoted to avoid defining a YAML dictionary
DOCKER_DATA: "{{ docker_data }}"
PLEX_GID: "{{ plex_group.gid }}"
PLEX_UID: "{{ plex_user.uid }}"
PLEX_MEDIA: "{{ plex_media }}"
---
all:
vars:
docker_data: /srv/
plex_media: /mnt/cloud/media
hosts:
children:
servers:
hosts:
cloud.xcjs.com:
vars:
hostname: CLOUD
# ...
- name: Create the plex user
user:
name: plex
create_home: no
system: yes
group: plex
# Registers task result as a variable named plex_user
register: plex_user
# ...
# Use plex_user.uid later to get the user's ID
# ...
- name: Clients
hosts: clients
ignore_errors: true
ignore_unreachable: true
roles:
# ...
# ...
x99.local:
ansible_become: false
ansible_connection: ssh
ansible_distribution: Microsoft Windows 10 Professional
ansible_shell_type: cmd
ansible_os_family: windows
ansible_user: Zack
vars:
docker_data: C:/srv/
# ...
---
- name: Execute the Ubuntu task list
when: ansible_distribution == "Ubuntu"
include_tasks: ubuntu.yml
- name: Execute the Windows task list
when: ansible_os_family == "windows"
include_tasks: windows.yml
---
- name: Install firefox
apt:
name: firefox
update_cache: yes
---
- name: Install firefox
win_chocolatey:
name: firefox
state: latest
| Branch | Stages | Jobs |
|---|---|---|
|
feature/*
(from master) (to staging) |
|
|
|
staging
(to master) |
|
|
| master |
|
|
---
# ...
Lint Playbooks:
stage: Lint
script:
- ansible-playbook -i 127.0.0.1, --syntax-check site-test-ubuntu.yml
- ansible-playbook -i 127.0.0.1, --syntax-check site-test-windows10.yml
- ansible-playbook -i inventory.yml --syntax-check site.yml
# ...
---
# ...
Test Ubuntu 18.04:
except:
refs:
- master
- staging
stage: Test
before_script:
- vagrant destroy --force
- vagrant plugin install vagrant-vbguest
- vagrant box update
script:
- vagrant up ubuntu
after_script:
- vagrant destroy --force
# ...
---
# ...
Dry Run:
only:
refs:
- master
- staging
stage: Test
script:
- ansible-playbook -i inventory.yml --check site.yml
# ...
---
# ...
Deploy:
only:
refs:
- master
stage: Deploy
script:
- ansible-playbook -i inventory.yml site.yml
# ...
Continue to CI/CD Optimization with a Case Study Involving Ansible and GitLab.
Return to the rest of the presentations.