|
1 | 1 | ---
|
2 |
| -# File: tasks/main.yml - Main tasks for nomad |
| 2 | +# File: tasks/main.yml - Main tasks for Nomad |
3 | 3 |
|
4 | 4 | - name: Check distribution compatibility
|
5 | 5 | fail:
|
|
8 | 8 |
|
9 | 9 | - name: Fail if not a new release of Red Hat / CentOS
|
10 | 10 | fail:
|
11 |
| - msg: "{{ ansible_distribution_version }} is not an acceptable version of {{ ansible_distribution }} for this role" |
| 11 | + msg: "{{ ansible_distribution_version }} is not a supported version of {{ ansible_distribution }} for this role" |
12 | 12 | when: ansible_distribution in ['RedHat', 'CentOS'] and ansible_distribution_version|version_compare(6, '<')
|
13 | 13 |
|
14 | 14 | - name: Fail if not a new release of Debian
|
15 | 15 | fail:
|
16 |
| - msg: "{{ ansible_distribution_version }} is not an acceptable version of {{ ansible_distribution }} for this role" |
| 16 | + msg: "{{ ansible_distribution_version }} is not a supported version of {{ ansible_distribution }} for this role" |
17 | 17 | when: ansible_distribution == "Debian" and ansible_distribution_version|version_compare(8.5, '<')
|
18 | 18 |
|
19 | 19 | - name: Fail if not a new release of Ubuntu
|
20 | 20 | fail:
|
21 |
| - msg: "{{ ansible_distribution_version }} is not an acceptable version of {{ ansible_distribution }} for this role" |
| 21 | + msg: "{{ ansible_distribution_version }} is not a supported version of {{ ansible_distribution }} for this role" |
22 | 22 | when: ansible_distribution == "Ubuntu" and ansible_distribution_version|version_compare(13.04, '<')
|
23 | 23 |
|
24 | 24 | - name: Create cluster groupings
|
25 |
| - group_by: key={{ nomad_node_role }} |
26 |
| - |
27 |
| -- group_by: key=os_{{ ansible_os_family }} |
28 |
| - |
29 |
| -- name: "Add nomad user" |
30 |
| - user: name=nomad comment="nomad user" uid=1047 group=bin |
31 |
| - |
32 |
| -- name: "Add nomad user to docker group" |
33 |
| - user: name=nomad groups=docker append=yes |
| 25 | + group_by: |
| 26 | + key: "{{ nomad_node_role }}" |
| 27 | + |
| 28 | +- group_by: |
| 29 | + key: "os_{{ ansible_os_family }}" |
| 30 | + |
| 31 | +- name: Add Nomad user |
| 32 | + user: |
| 33 | + name: nomad |
| 34 | + comment: "Nomad user" |
| 35 | + uid: 1047 |
| 36 | + group: bin |
| 37 | + |
| 38 | +- name: Add Nomad user to docker group |
| 39 | + user: |
| 40 | + name: nomad |
| 41 | + groups: docker |
| 42 | + append: yes |
34 | 43 | when: nomad_enable_docker == "true"
|
35 | 44 |
|
36 |
| -# Include variables and define needed variables. |
37 |
| -- name: Include OS-specific variables. |
| 45 | +- name: Include OS variables |
38 | 46 | include_vars: "{{ ansible_os_family }}.yml"
|
39 |
| - |
40 |
| -- name: Install specified packages |
| 47 | + |
| 48 | +- name: Install OS packages |
41 | 49 | include: install.yml
|
42 | 50 |
|
43 | 51 | - name: Disable SELinux (RHEL)
|
44 | 52 | include: selinux.yml
|
45 | 53 | when: ansible_os_family == "RedHat"
|
46 | 54 |
|
47 |
| -- name: Directories |
48 |
| - file: "dest={{ item }} state=directory owner={{ nomad_user }} group={{ nomad_group}}" |
| 55 | +- name: Create directories |
| 56 | + file: |
| 57 | + dest: "{{ item }}" |
| 58 | + state: directory |
| 59 | + owner: "{{ nomad_user }}" |
| 60 | + group: "{{ nomad_group}}" |
49 | 61 | with_items:
|
50 | 62 | - /opt/nomad
|
51 | 63 | - /var/nomad
|
52 | 64 | - /var/run/nomad
|
53 | 65 | - /etc/nomad.d
|
54 | 66 |
|
55 | 67 | - name: Base configuration
|
56 |
| - template: src=base.hcl.j2 dest={{ nomad_config_dir }}/base.hcl |
| 68 | + template: |
| 69 | + src: base.hcl.j2 |
| 70 | + dest: "{{ nomad_config_dir }}/base.hcl" |
57 | 71 |
|
58 | 72 | - name: Bootstrap server configuration
|
59 |
| - template: src=bootstrap.hcl.j2 dest={{ nomad_config_dir }}/bootstrap.hcl |
| 73 | + template: |
| 74 | + src: bootstrap.hcl.j2 |
| 75 | + dest: "{{ nomad_config_dir }}/bootstrap.hcl" |
60 | 76 |
|
61 | 77 | - name: Server configuration
|
62 |
| - template: src=server.hcl.j2 dest={{ nomad_config_dir }}/server.hcl |
| 78 | + template: |
| 79 | + src: server.hcl.j2 |
| 80 | + dest: "{{ nomad_config_dir }}/server.hcl" |
63 | 81 |
|
64 | 82 | - name: Client configuration
|
65 |
| - template: src=client.hcl.j2 dest={{ nomad_config_dir }}/client.hcl |
| 83 | + template: |
| 84 | + src: client.hcl.j2 |
| 85 | + dest: "{{ nomad_config_dir }}/client.hcl" |
66 | 86 |
|
67 | 87 | - name: SYSV init script
|
68 |
| - template: src=nomad_sysvinit.j2 dest=/etc/init.d/nomad owner=root group=root mode=755 |
| 88 | + template: |
| 89 | + src: nomad_sysvinit.j2 |
| 90 | + dest: /etc/init.d/nomad |
| 91 | + owner: root |
| 92 | + group: root |
| 93 | + mode: 0755 |
69 | 94 | when: not ansible_service_mgr == "systemd" and not ansible_os_family == "Debian"
|
70 | 95 |
|
71 | 96 | - name: Debian init script
|
72 |
| - template: src=nomad_debian.init.j2 dest=/etc/init.d/nomad owner=root group=root mode=755 |
| 97 | + template: |
| 98 | + src: nomad_debian.init.j2 |
| 99 | + dest: /etc/init.d/nomad |
| 100 | + owner: root |
| 101 | + group: root |
| 102 | + mode: 0755 |
73 | 103 | when: not ansible_service_mgr == "systemd" and ansible_os_family == "Debian"
|
74 | 104 |
|
75 | 105 | - name: systemd script
|
76 |
| - template: src=nomad_systemd.service.j2 dest=/lib/systemd/system/nomad.service owner=root group=root mode=644 |
| 106 | + template: |
| 107 | + src: nomad_systemd.service.j2 |
| 108 | + dest: /lib/systemd/system/nomad.service |
| 109 | + owner: root |
| 110 | + group: root |
| 111 | + mode: 644 |
77 | 112 | when: ansible_service_mgr == "systemd"
|
78 | 113 |
|
79 | 114 | - name: Start Nomad
|
80 |
| - service: name=nomad state=started |
| 115 | + service: |
| 116 | + name: nomad |
| 117 | + enabled: yes |
| 118 | + state: started |
0 commit comments