main.yml 1.17 KB
Newer Older
1
---
2
3
- name: Install CentOS consul depends
  yum:
4
    name: python-virtualenv
5
    state: present
Aleksey Shirokih's avatar
Aleksey Shirokih committed
6
    update_cache: "True"
7
8
9
10
11
12
  environment:
    https_proxy: "{{ http_proxy }}"
    http_proxy: "{{ http_proxy }}"
  tags:
    - requirements

Aleksey Shirokih's avatar
Aleksey Shirokih committed
13
14
15
16
17
18
19
20
21
22
23
24
25
26
- name: systemd script
  template:
    src: consul_systemd.service.j2
    dest: /lib/systemd/system/consul.service
    owner: root
    group: root
    mode: 0644
  tags:
    - config
  notify:
    - reload systemd
    - restart consul

- name: check firewalld state
27
28
  systemd:
    name: firewalld
Aleksey Shirokih's avatar
Aleksey Shirokih committed
29
  check_mode: "True"
Aleksey Shirokih's avatar
Aleksey Shirokih committed
30
  register: firewalld_state
Aleksey Shirokih's avatar
Aleksey Shirokih committed
31
32
  changed_when: "False"
  ignore_errors: "True"
Aleksey Shirokih's avatar
Aleksey Shirokih committed
33
34
35
36
37
38
  tags:
    - config
    - firewall

- name: Add firewall permissions for nodes
  firewalld:
EKbfh's avatar
EKbfh committed
39
    port: "{{ item }}"
Aleksey Shirokih's avatar
Aleksey Shirokih committed
40
    permanent: "True"
Aleksey Shirokih's avatar
Aleksey Shirokih committed
41
    state: enabled
Aleksey Shirokih's avatar
Aleksey Shirokih committed
42
    immediate: "True"
43
  when: "firewalld_state.status.ActiveState == 'active'"
44
  with_items:
Aleksey Shirokih's avatar
Aleksey Shirokih committed
45
46
47
48
49
50
51
52
53
54
55
56
    - 8300/tcp
    - 8301/tcp
    - 8301/udp
    - 8302/tcp
    - 8302/udp
    - 8500/tcp
  tags:
    - config
    - firewall

- name: Expose consul_bind_address as fact
  set_fact:
EKbfh's avatar
EKbfh committed
57
    consul_bind_address: "{{ consul_address }}"
Aleksey Shirokih's avatar
Aleksey Shirokih committed
58
59
60
  when:
    - consul_address is defined
    - consul_address!='node_ip'
Aleksey Shirokih's avatar
Aleksey Shirokih committed
61
  tags:
Aleksey Shirokih's avatar
Aleksey Shirokih committed
62
    - config