Skip to content

Commit 182e610

Browse files
committed
Handle FIXME about the hosts file
An even better fix is to make the inventory better structured so moving these hosts is easier. The other proper fix is to make playbooks more idempotent so rerunning is not a problem but thats technical debt for now.
1 parent 56d76d7 commit 182e610

File tree

3 files changed

+24
-14
lines changed

3 files changed

+24
-14
lines changed

provision-contest/ansible/hosts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
ansible_user=root
33
ansible_python_interpreter=/usr/bin/python3
44

5+
# When moving clients for ad-hoc actions:
6+
# move them to their own group to keep hosts files on deployed machines in sync.
7+
58
[domserver]
69
domjudge-primary ansible_host=10.3.3.216 KEEPALIVED_PRIORITY=100 EFI_ORDER='0\,1\,3\,4'
710
domjudge-backup ansible_host=10.3.3.217 KEEPALIVED_PRIORITY=99 EFI_ORDER='0\,1\,3\,4'

provision-contest/ansible/roles/hosts/tasks/main.yml

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,11 @@
55
hostname:
66
name: "{{ inventory_hostname }}"
77

8-
# FIXME: this needs to be cleaned up and done in a way such that the
9-
# tasks are not marked as "changed" every time they are run, and also
10-
# work better with ad-hoc editing of the inventory hosts file.
11-
12-
- name: add all hosts to hosts file
13-
lineinfile:
8+
- name: Set new hosts file
9+
template:
10+
src: hosts.j2
1411
dest: /etc/hosts
15-
regexp: '{{ item }}$'
16-
line: "{{ hostvars[item].ansible_host }} {{ item }}"
17-
loop: "{{ groups['all'] }}"
12+
group: root
13+
owner: root
14+
mode: 0644
1815

19-
- name: add domjudge in hosts file
20-
lineinfile:
21-
dest: /etc/hosts
22-
regexp: 'domserver'
23-
line: "{{ DOMSERVER_IP }} domjudge domserver"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
127.0.0.1 localhost
2+
127.0.1.1 {{ inventory_hostname }}
3+
4+
# The following lines are desirable for IPv6 capable hosts
5+
::1 ip6-localhost ip6-loopback
6+
fe00::0 ip6-localnet
7+
ff00::0 ip6-mcastprefix
8+
ff02::1 ip6-allnodes
9+
ff02::2 ip6-allrouters
10+
11+
{{ DOMSERVER_IP }} domjudge domserver
12+
{% for item in groups['all'] %}
13+
{{ hostvars[item].ansible_host }} {{ item }}
14+
{% endfor %}
15+

0 commit comments

Comments
 (0)