summaryrefslogtreecommitdiff
path: root/ansible/roles/trove-setup/tasks/minions.yml
blob: 929f893b09f955ba2d3f382bd0309d7453961814 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Depends on:
# - lorry-controller-setup.yml
---
# This is a workaround because the service module and the current
# systemd version doesn't work well enough with template units.
#
# Ansible runs the following to check the status of a systemd unit:
#
#   systemctl show <name-of-unit>
#
# With template units, this command will say to Ansible that the unit
# "lorry-controller-minion@2" is running and enabled when only
# "lorry-controller-minion@1" is. That's why this workaround is needed.
#
# It ALWAYS runs `systemctl enable` for all the minions to be
# created, but it only reports that the status of the task has changed
# when in the stderr output is the string "ln -s" (which means the
# unit has been enabled).
- name: Enable as many MINIONS as specified in LORRY_CONTROLLER_MINIONS
  shell: systemctl enable lorry-controller-minion@{{ item }}.service
  with_sequence: count={{ LORRY_CONTROLLER_MINIONS }}
  changed_when: "'Created symlink' in minions_creation.stderr"
  register: minions_creation

- name: Start the all the MINIONS created (if any)
  service: name=lorry-controller-minion@{{ item.item }} state=restarted
  with_items: minions_creation.results
  when: item|changed