115 lines
3.0 KiB
YAML
115 lines
3.0 KiB
YAML
---
|
|
- name: Prepare
|
|
hosts: zabbix_server
|
|
pre_tasks:
|
|
- name: "Installing EPEL"
|
|
ansible.builtin.yum:
|
|
name:
|
|
- epel-release
|
|
state: present
|
|
when: ansible_distribution == 'CentOS'
|
|
|
|
- name: "Installing packages"
|
|
ansible.builtin.yum:
|
|
name:
|
|
- net-tools
|
|
- which
|
|
- libselinux-python
|
|
- python-pip
|
|
state: present
|
|
register: installation_dependencies
|
|
when: ansible_distribution == 'CentOS'
|
|
|
|
- name: "Installing which on NON-CentOS"
|
|
ansible.builtin.apt:
|
|
name:
|
|
- net-tools
|
|
- python-pip
|
|
- curl
|
|
state: present
|
|
when: ansible_distribution != 'CentOS'
|
|
|
|
- name: "Configure SUDO."
|
|
ansible.builtin.lineinfile:
|
|
dest: /etc/sudoers
|
|
line: "Defaults !requiretty"
|
|
state: present
|
|
|
|
- name: "Make sure the docs are installed."
|
|
ansible.builtin.lineinfile:
|
|
dest: /etc/yum.conf
|
|
line: "tsflags=nodocs"
|
|
state: absent
|
|
|
|
- name: "Installing some python dependencies"
|
|
ansible.builtin.pip:
|
|
name: py-zabbix
|
|
state: present
|
|
|
|
roles:
|
|
- role: geerlingguy.mysql
|
|
- role: zabbix_server
|
|
- role: zabbix_web
|
|
|
|
- name: Prepare
|
|
hosts: all:!zabbix_server:!docker
|
|
tasks:
|
|
- name: "Installing packages on CentOS family"
|
|
ansible.builtin.yum:
|
|
name:
|
|
- net-tools
|
|
- which
|
|
state: present
|
|
when:
|
|
- ansible_os_family == 'RedHat'
|
|
|
|
- name: "Installing packages on Debian family"
|
|
ansible.builtin.apt:
|
|
name:
|
|
- net-tools
|
|
state: present
|
|
when:
|
|
- ansible_os_family == 'Debian'
|
|
|
|
- name: Converge
|
|
hosts: docker
|
|
tasks:
|
|
- name: "Download Docker CE repo file"
|
|
ansible.builtin.get_url:
|
|
url: https://download.docker.com/linux/centos/docker-ce.repo
|
|
dest: /etc/yum.repos.d/docker-ce.repo
|
|
mode: 0644
|
|
register: zabbix_agent_prepare_docker_repo
|
|
until: zabbix_agent_prepare_docker_repo is succeeded
|
|
|
|
- name: "Installing Epel"
|
|
ansible.builtin.package:
|
|
pkg:
|
|
- epel-release
|
|
state: present
|
|
register: zabbix_agent_prepare_docker_install
|
|
until: zabbix_agent_prepare_docker_install is succeeded
|
|
|
|
- name: "Installing Docker"
|
|
ansible.builtin.package:
|
|
pkg:
|
|
- docker-ce
|
|
- python-pip
|
|
- python-setuptools
|
|
state: present
|
|
register: zabbix_agent_prepare_docker_install
|
|
until: zabbix_agent_prepare_docker_install is succeeded
|
|
|
|
- name: "Installing Docker Python"
|
|
ansible.builtin.pip:
|
|
name:
|
|
- docker
|
|
state: present
|
|
register: zabbix_agent_prepare_docker_install
|
|
until: zabbix_agent_prepare_docker_install is succeeded
|
|
|
|
- name: "Starting Docker service"
|
|
ansible.builtin.service:
|
|
name: docker
|
|
state: started
|