-
Notifications
You must be signed in to change notification settings - Fork 4
Ansible
I'm finding Ansible to be a pain. for the some of the same reasons as Salt.
This issue explains the problem, but here's the code:
- name: add container-storage-setup
args:
creates: "{{ docker.dm.thinpooldev }}"
executable: /bin/bash
shell: |
set -e
cd /tmp
rm -rf container-storage-setup
git clone https://github.com/projectatomic/container-storage-setup
cd container-storage-setup
rm -rf container-storage-setup
cat > rs-conf <<'EOF'
CONTAINER_THINPOOL='{{ docker.dm.thinpool }}'
VG='{{ docker.dm.volume_group }}'
DEVS='{{ docker.dm.block_device }}'
EOF
bash container-storage-setup.sh rs-conf ignore-output
cd ..
rm -rf container-storage-setup
This correct YAML ends up failing, because shell
puts a leading space on
all lines so that the script looks like:
set -e
cd /tmp
rm -rf container-storage-setup
git clone https://github.com/projectatomic/container-storage-setup
cd container-storage-setup
rm -rf container-storage-setup
cat > rs-conf <<'EOF'
CONTAINER_THINPOOL='{{ docker.dm.thinpool }}'
VG='{{ docker.dm.volume_group }}'
DEVS='{{ docker.dm.block_device }}'
EOF
bash container-storage-setup.sh rs-conf ignore-output
cd ..
rm -rf container-storage-setup
Which unfortunately creates a file rs-conf, but doesn't run container-storage-setup.sh.
Now even though shell
knows {{ docker.dm.thinpooldev }}
should be created,
it isn't, but the task completes, docker then fails to start.
It would be better to have a single script that creates the storage and enables Docker.
Does not restart:
- name: restart firewalld
service: name=firewalld state=restarted
If you get a failure, then it doesn't restart. exportfs
is idempotent, just run it.
Includes ~
backup files from emacs as variables.
meta/main.yml and defaults/main.yml do not accept Jinja:
ERROR! Syntax Error while loading YAML.
The error appears to have been in '/var/lib/ansible/ansible-conf/roles/mpi_cluster/defaults/main.yml': line 37, column 8, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
mpi_bin_d: /var/lib/jupyter/mpi_bin
{% if rs_role == "mpi_cluster_coordinator" %}
^ here
In general, too many syntaxes: ansible.cfg, inventory, variables, tasks, files/directories, etc.