Get a cup of coffee. ☕
Quick demo of what Ansible does.
Why use it?
Why it’s super cool.
Configuration management tool.
Automated control of server state.
First we need to look at how applications are deployed in general.
There are different processes, but generally, applications are deployed via:
apt
)./configure; make; ...
)Either way, all these need to be run in shells, essentially.
These are the easiest (?) way to automate a server’s configuration.
Just rewrite the commands you ran when you first manually installed a software.
Some software provides these out-of-the-box.
Not really.
We just want to have an easier method to manage small snippets we can run to deploy software.
Made by Red Hat.
Designed to be a sequence of small shell scripts run on the server, provided as Ansible modules.
Essentially, Ansible takes our input (YAML files) and constructs a set of tasks to run.
This set of tasks is run on any nodes we want it to in order, and declaratively sets up our nodes.
Nothing is run if everything is fine.
“We love Shakespare.” - Red Hat, probably.
ansible-playbook -i inventory.file playbook.yml
I’ll show you a simple example of an Ansible playbook that installs Slurm on Ubuntu 20.04.
- name: Setup Slurm nodes
hosts: slurm-nodes
remote_user: root
tasks:
- name: Ensure Slurm is installed and updated.
ansible.builtin.apt:
name: slurm-wlm
state: latest
- name: Upload previously configured Slurm configuration file.
ansible.builtin.copy:
src: ./slurm.config
dest: /etc/slurm-llnl/slurm.config
backup: yes
- name: Ensure Slurm service is enabled and running.
ansible.builtin.systemd:
state: restarted
enabled: yes
name: slurmd
You’d be correct.
Thankfully, we have this cool thing called roles.
Can be reused across different plays. (i.e. many servers might need a database)
What if we just shared these roles with others?
“Package manager” for Ansible roles.
You can probably Google “[_] Ansible role” and find what you want.
Surely that doesn’t always work…
Mostly syntax.
You also require a ansible-galaxy
download:
ansible-galaxy install -r requirements.yml
- name: Setup Slurm nodes
hosts: slurm-nodes
remote_user: root
vars:
slurm_roles: ['controller', 'exec', 'dbd']
roles:
- role: galaxyproject.slurm
become: True
tasks:
- name: Upload previously configured Slurm configuration file.
ansible.builtin.copy:
src: ./slurm.config
dest: /etc/slurm-llnl/slurm.config
backup: yes
Quite well actually.
A few.
In my opinion.
YAML is a poor file format for configuration.
Should not be necessary in a configuration file.
Machine-friendly configuration is nicer for automation.
You will never know.
Many, many edgecases.