main.yml 1.18 KB
Newer Older
1
---
2
3
4
5
6
7
8
9
10
11
12
13
14
- name: Install CentOS consul depends
  yum:
    name: "{{ item }}"
    state: present
    update_cache: yes
  with_items:
   - python-virtualenv
  environment:
    https_proxy: "{{ http_proxy }}"
    http_proxy: "{{ http_proxy }}"
  tags:
    - requirements

Aleksey Shirokih's avatar
Aleksey Shirokih committed
15
16
17
18
19
20
21
22
23
24
25
26
27
28
- 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
29
30
31
  systemd:
    name: firewalld
  check_mode: yes
Aleksey Shirokih's avatar
Aleksey Shirokih committed
32
33
34
35
36
37
38
39
40
41
42
43
44
  register: firewalld_state
  changed_when: false
  ignore_errors: yes
  tags:
    - config
    - firewall

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

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