summaryrefslogtreecommitdiffstats
path: root/collections-debian-merged/ansible_collections/community/zabbix/molecule/zabbix_proxy/prepare.yml
blob: 67b5aaa6bba13a805c481a984f2401ac5f121f91 (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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
---
- name: Prepare
  hosts: localhost
  connection: local
  pre_tasks:

    - name: "Create MySQL Container"
      docker_container:
        name: mysql-host
        image: mysql:5.7
        state: started
        recreate: yes
        networks:
          - name: zabbix
        env:
          MYSQL_ROOT_PASSWORD: changeme
      no_log: true
      with_items: "{{ molecule_yml.platforms }}"
      when:
        - '"mysql" in item.groups'

    - name: "Create postgresql Container"
      docker_container:
        name: postgresql-host
        image: postgres
        state: started
        recreate: yes
        networks:
          - name: zabbix
        env:
          POSTGRES_PASSWORD: changeme
      no_log: true
      with_items: "{{ molecule_yml.platforms }}"
      when:
        - '"postgresql" in item.groups'

- name: Prepare
  hosts: all
  tasks:

    - name: "Set short version name"
      set_fact:
        zabbix_python_prefix: "python{% if ansible_python_version is version('3', '>=') %}3{% endif %}"

    - name: "Create group for imaginary host"
      add_host:
        name: imaginary-host
        groups:
          - mysql
          - postgresql
      changed_when: False

    - name: "Installing packages on CentOS"
      yum:
        name:
          - net-tools
          - which
          - sudo
        state: present
      register: installation_dependencies
      until: installation_dependencies is succeeded
      when:
        - ansible_os_family == 'RedHat'

    - name: "Installing packages on CentOS"
      yum:
        name:
          - mysql
        state: present
      register: installation_dependencies
      until: installation_dependencies is succeeded
      when:
        - ansible_os_family == 'RedHat'
        - inventory_hostname in groups['mysql']

    - name: "Apt update"
      shell: "apt-get update && echo exit 0 > /usr/sbin/policy-rc.d"
      args:
        warn: False
      register: installation_dependencies
      until: installation_dependencies is succeeded
      when:
        - ansible_os_family != 'RedHat'

    - name: "Installing packages on NON-CentOS"
      apt:
        name:
          - net-tools
          - apt-utils
          - "{{ zabbix_python_prefix }}-pip"
          - gpg-agent
          - sudo
          - doc-base
        update_cache: True
        state: present
      register: installation_dependencies
      until: installation_dependencies is succeeded
      when:
        - ansible_os_family != 'RedHat'

    - name: "Configure SUDO."
      lineinfile:
        dest: /etc/sudoers
        line: "Defaults    !requiretty"
        state: present

    - name: "Make sure the docs can be installed. (RedHat)"
      lineinfile:
        dest: /etc/yum.conf
        line: "tsflags=nodocs"
        state: absent
      when:
        - ansible_os_family == 'RedHat'

    - name: "Make sure the docs can be installed. (Debian)"
      lineinfile:
        path: /etc/dpkg/dpkg.cfg.d/excludes
        state: absent
        regexp: 'path-exclude=/usr/share/doc/*'
      when:
        - ansible_os_family != 'RedHat'

    - name: PyMySQL
      pip:
        name: PyMySQL
      register: installation_dependencies
      until: installation_dependencies is succeeded
      when:
        - inventory_hostname in groups['mysql']