From 9cd33c14bb126b42b5018d7e4fedf60af653c898 Mon Sep 17 00:00:00 2001 From: Pablo Estigarribia Date: Sun, 6 Jan 2019 02:43:27 -0300 Subject: [PATCH 01/12] add tests to thruk and compatibility with newer distros --- .travis.yml | 23 ++++++++ ansible.cfg | 18 ++++++ meta/main.yml | 13 ++-- molecule/default/Dockerfile.j2 | 24 ++++++++ molecule/default/INSTALL.rst | 16 +++++ molecule/default/create.yml | 59 +++++++++++++++++++ molecule/default/destroy.yml | 27 +++++++++ molecule/default/molecule.yml | 75 ++++++++++++++++++++++++ molecule/default/playbook.yml | 8 +++ molecule/default/prepare.yml | 5 ++ molecule/default/tests/test_default.py | 14 +++++ molecule/default/tests/test_default.pyc | Bin 0 -> 1021 bytes molecule/local/Dockerfile.j2 | 24 ++++++++ molecule/local/INSTALL.rst | 16 +++++ molecule/local/create.yml | 59 +++++++++++++++++++ molecule/local/destroy.yml | 27 +++++++++ molecule/local/molecule.yml | 75 ++++++++++++++++++++++++ molecule/local/playbook.yml | 8 +++ molecule/local/prepare.yml | 5 ++ molecule/local/tests/test_default.py | 14 +++++ molecule/local/tests/test_default.pyc | Bin 0 -> 1021 bytes requirements.yml | 13 ++++ run_local_molecule.sh | 7 +++ run_local_molecule_basic.sh | 29 +++++++++ run_local_molecule_destroy.sh | 10 ++++ tasks/config_nagios.yml | 2 +- tasks/multi_os.yml | 7 +++ vars/{Ubuntu.yml => Debian-7.yml} | 8 --- vars/Debian-8.yml | 54 +++++++++++++++++ vars/Debian.yml | 50 ++++++++++++++++ vars/Ubuntu-14.yml | 54 +++++++++++++++++ 31 files changed, 731 insertions(+), 13 deletions(-) create mode 100644 .travis.yml create mode 100644 ansible.cfg create mode 100644 molecule/default/Dockerfile.j2 create mode 100644 molecule/default/INSTALL.rst create mode 100644 molecule/default/create.yml create mode 100644 molecule/default/destroy.yml create mode 100644 molecule/default/molecule.yml create mode 100644 molecule/default/playbook.yml create mode 100644 molecule/default/prepare.yml create mode 100644 molecule/default/tests/test_default.py create mode 100644 molecule/default/tests/test_default.pyc create mode 100644 molecule/local/Dockerfile.j2 create mode 100644 molecule/local/INSTALL.rst create mode 100644 molecule/local/create.yml create mode 100644 molecule/local/destroy.yml create mode 100644 molecule/local/molecule.yml create mode 100644 molecule/local/playbook.yml create mode 100644 molecule/local/prepare.yml create mode 100644 molecule/local/tests/test_default.py create mode 100644 molecule/local/tests/test_default.pyc create mode 100644 requirements.yml create mode 100644 run_local_molecule.sh create mode 100644 run_local_molecule_basic.sh create mode 100644 run_local_molecule_destroy.sh rename vars/{Ubuntu.yml => Debian-7.yml} (89%) create mode 100644 vars/Debian-8.yml create mode 100644 vars/Debian.yml create mode 100644 vars/Ubuntu-14.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..fe32e65 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,23 @@ +# http://www.jeffgeerling.com/blog/testing-ansible-roles-travis-ci-github +sudo: required +language: python +services: + - docker +before_install: + - sudo apt-get -qq update + #- docker build --tag molecule_local/fedora-rawhide2:latest -f molecule/default/fedorar/Dockerfile molecule/default/fedorar + +install: + - sudo apt-get install -y python-pip libssl-dev libffi-dev + - pip install molecule + - pip install docker-py + #- ansible-galaxy install -r requirements.yml + +script: + - molecule --debug create + - molecule converge + - molecule syntax + #- molecule idempotence + +notifications: + webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/ansible.cfg b/ansible.cfg new file mode 100644 index 0000000..dd24de7 --- /dev/null +++ b/ansible.cfg @@ -0,0 +1,18 @@ +# config file for ansible -- http://ansible.com/ +# ============================================== + +# nearly all parameters can be overridden in ansible-playbook +# or with command line flags. ansible will read ANSIBLE_CONFIG, +# ansible.cfg in the current working directory, .ansible.cfg in +# the home directory or /etc/ansible/ansible.cfg, whichever it +# finds first + +[defaults] +roles_path = ../:/etc/ansible/roles:~/.ansible/roles +host_key_checking = False + +retry_files_enabled = False +callback_whitelist = profile_tasks + +[ssh_connection] +pipelining = False diff --git a/meta/main.yml b/meta/main.yml index df5bffc..3eb4f3c 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -8,11 +8,16 @@ galaxy_info: - name: Ubuntu versions: - trusty + - xenial + - bionic + - name: Debian + versions: + - all galaxy_tags: - - Monitoring - - Infraestructure + - monitoring + - infraestructure allow_duplicates: no dependencies: - - role: nagios4_checkmk_livestatus + - role: coffeeitworks.ansible_nagios4_checkmk_livestatus tags: ["install", "nagios_server_all", "nagios_server"] -# - { role: ANXS.mysql, tags: ["install", "nagios_server_all", "nagios_server_thruk", "ANXS.mysql"] } \ No newline at end of file +# - { role: ANXS.mysql, tags: ["install", "nagios_server_all", "nagios_server_thruk", "ANXS.mysql"] } diff --git a/molecule/default/Dockerfile.j2 b/molecule/default/Dockerfile.j2 new file mode 100644 index 0000000..491096f --- /dev/null +++ b/molecule/default/Dockerfile.j2 @@ -0,0 +1,24 @@ +# Molecule managed + +FROM {{ item.image }} + +RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get upgrade -y && apt-get install -y python sudo bash ca-certificates && apt-get clean; \ + elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python2-dnf bash && dnf clean all; \ + elif [ $(command -v yum) ]; then yum makecache fast && yum update -y && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \ + elif [ $(command -v zypper) ]; then zypper refresh && zypper update -y && zypper install -y python sudo bash python-xml && zypper clean -a; \ + elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; fi + +RUN if [ $(command -v dnf) ]; then dnf -y update && dnf clean all; fi + +RUN if [ $(command -v dnf) ]; then dnf -y install systemd hostname && dnf clean all && \ +(cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \ +rm -f /lib/systemd/system/multi-user.target.wants/*;\ +rm -f /etc/systemd/system/*.wants/*;\ +rm -f /lib/systemd/system/local-fs.target.wants/*; \ +rm -f /lib/systemd/system/sockets.target.wants/*udev*; \ +rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \ +rm -f /lib/systemd/system/basic.target.wants/*;\ +rm -f /lib/systemd/system/anaconda.target.wants/*; fi + +# VOLUME [ "/sys/fs/cgroup" ] +# CMD ["/usr/sbin/init"] diff --git a/molecule/default/INSTALL.rst b/molecule/default/INSTALL.rst new file mode 100644 index 0000000..e26493b --- /dev/null +++ b/molecule/default/INSTALL.rst @@ -0,0 +1,16 @@ +******* +Install +******* + +Requirements +============ + +* Docker Engine +* docker-py + +Install +======= + +.. code-block:: bash + + $ sudo pip install docker-py diff --git a/molecule/default/create.yml b/molecule/default/create.yml new file mode 100644 index 0000000..bfb2149 --- /dev/null +++ b/molecule/default/create.yml @@ -0,0 +1,59 @@ +--- +- name: Create + hosts: localhost + connection: local + gather_facts: false + no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}" + vars: + molecule_file: "{{ lookup('env', 'MOLECULE_FILE') }}" + molecule_ephemeral_directory: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}" + molecule_scenario_directory: "{{ lookup('env', 'MOLECULE_SCENARIO_DIRECTORY') }}" + molecule_yml: "{{ lookup('file', molecule_file) | molecule_from_yaml }}" + tasks: + - name: Create Dockerfiles from image names + template: + src: "{{ molecule_scenario_directory }}/Dockerfile.j2" + dest: "{{ molecule_ephemeral_directory }}/Dockerfile_{{ item.image | regex_replace('[^a-zA-Z0-9_]', '_') }}" + with_items: "{{ molecule_yml.platforms }}" + register: platforms + + - name: Discover local Docker images + docker_image_facts: + name: "molecule_local/{{ item.item.name }}" + with_items: "{{ platforms.results }}" + register: docker_images + + - name: Build an Ansible compatible image + docker_image: + path: "{{ molecule_ephemeral_directory }}" + name: "molecule_local/{{ item.item.image }}" + dockerfile: "{{ item.item.dockerfile | default(item.invocation.module_args.dest) }}" + force: "{{ item.item.force | default(true) }}" + with_items: "{{ platforms.results }}" + when: platforms.changed or docker_images.results | map(attribute='images') | select('equalto', []) | list | count >= 0 + + - name: Create molecule instance(s) + docker_container: + name: "{{ item.name }}" + hostname: "{{ item.name }}" + image: "molecule_local/{{ item.image }}" + state: started + recreate: false + log_driver: syslog + command: "{{ item.command | default('bash -c \"while true; do sleep 10000; done\"') }}" + privileged: "{{ item.privileged | default(omit) }}" + volumes: "{{ item.volumes | default(omit) }}" + capabilities: "{{ item.capabilities | default(omit) }}" + ports: "{{ item.exposed_ports | default(omit) }}" + register: server + with_items: "{{ molecule_yml.platforms }}" + async: 7200 + poll: 0 + + - name: Wait for instance(s) creation to complete + async_status: + jid: "{{ item.ansible_job_id }}" + register: docker_jobs + until: docker_jobs.finished + retries: 300 + with_items: "{{ server.results }}" diff --git a/molecule/default/destroy.yml b/molecule/default/destroy.yml new file mode 100644 index 0000000..3ce7478 --- /dev/null +++ b/molecule/default/destroy.yml @@ -0,0 +1,27 @@ +--- +- name: Destroy + hosts: localhost + connection: local + gather_facts: false + no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}" + vars: + molecule_file: "{{ lookup('env', 'MOLECULE_FILE') }}" + molecule_yml: "{{ lookup('file', molecule_file) | molecule_from_yaml }}" + tasks: + - name: Destroy molecule instance(s) + docker_container: + name: "{{ item.name }}" + state: absent + force_kill: "{{ item.force_kill | default(true) }}" + register: server + with_items: "{{ molecule_yml.platforms }}" + async: 7200 + poll: 0 + + - name: Wait for instance(s) deletion to complete + async_status: + jid: "{{ item.ansible_job_id }}" + register: docker_jobs + until: docker_jobs.finished + retries: 300 + with_items: "{{ server.results }}" diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml new file mode 100644 index 0000000..c64c09c --- /dev/null +++ b/molecule/default/molecule.yml @@ -0,0 +1,75 @@ +--- +dependency: + name: galaxy + options: + ignore-certs: True + ignore-errors: True + role-file: requirements.yml +driver: + name: docker +lint: + name: yamllint +platforms: + + - name: ansible_test-01 + image: paulfantom/ubuntu-molecule:16.04 + #privileged: True + command: /sbin/init + capabilities: + - SYS_ADMIN + volumes: + - "/sys/fs/cgroup:/sys/fs/cgroup:ro" + groups: + - group1 + + - name: ansible_test-01_2 + image: paulfantom/ubuntu-molecule:18.04 + #privileged: True + command: /sbin/init + capabilities: + - SYS_ADMIN + volumes: + - "/sys/fs/cgroup:/sys/fs/cgroup:ro" + groups: + - group1 + + - name: ansible_test-02 + image: ubuntu:trusty + groups: + - groupold +# +# - name: ansible_test-03 +# image: centos/systemd +# command: /sbin/init +# capabilities: +# - SYS_ADMIN +# volumes: +# - "/sys/fs/cgroup:/sys/fs/cgroup:ro" + #privileged: True +# groups: +# - group1 + +provisioner: + name: ansible + config_options: + defaults: + callback_whitelist: profile_tasks + inventory: + group_vars: + master: + burpsrcext: "zip" + burp_version: "master" + burp_remove_clients: + - name: client_to_remove + - name: other_client_to_remove + burp_server_port_per_operation_bool: true + lint: + name: ansible-lint + +scenario: + name: default + +verifier: + name: testinfra + lint: + name: flake8 diff --git a/molecule/default/playbook.yml b/molecule/default/playbook.yml new file mode 100644 index 0000000..5747ab0 --- /dev/null +++ b/molecule/default/playbook.yml @@ -0,0 +1,8 @@ +--- +- name: Converge + hosts: all + roles: + - role: geerlingguy.mysql + - role: ansible-role-nagios + - role: coffeeitworks.ansible_nagios4_server_config + - role: ansible_nagios4_server_thruk diff --git a/molecule/default/prepare.yml b/molecule/default/prepare.yml new file mode 100644 index 0000000..5358b3b --- /dev/null +++ b/molecule/default/prepare.yml @@ -0,0 +1,5 @@ +--- +- name: Prepare + hosts: all + gather_facts: false + tasks: [] diff --git a/molecule/default/tests/test_default.py b/molecule/default/tests/test_default.py new file mode 100644 index 0000000..eedd64a --- /dev/null +++ b/molecule/default/tests/test_default.py @@ -0,0 +1,14 @@ +import os + +import testinfra.utils.ansible_runner + +testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( + os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') + + +def test_hosts_file(host): + f = host.file('/etc/hosts') + + assert f.exists + assert f.user == 'root' + assert f.group == 'root' diff --git a/molecule/default/tests/test_default.pyc b/molecule/default/tests/test_default.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6cb13885d34eb737362538b4b6e3c4c2a62a8450 GIT binary patch literal 1021 zcmdr~&2H2%5FRJnUs3i{pW5|#i`eh>`6t{?ge-! z9)XA9$OFLG*|ep+0ZBX_e;I!>{>I_2t#~}n&e06 zha`P>Jo}ixI+`Zv(ic*ejOJiD4r#ViGS`&KS40UG46Z331G@_tz?Xg*x= 0 + + - name: Create molecule instance(s) + docker_container: + name: "{{ item.name }}" + hostname: "{{ item.name }}" + image: "molecule_local/{{ item.image }}" + state: started + recreate: false + log_driver: syslog + command: "{{ item.command | default('bash -c \"while true; do sleep 10000; done\"') }}" + privileged: "{{ item.privileged | default(omit) }}" + volumes: "{{ item.volumes | default(omit) }}" + capabilities: "{{ item.capabilities | default(omit) }}" + ports: "{{ item.exposed_ports | default(omit) }}" + register: server + with_items: "{{ molecule_yml.platforms }}" + async: 7200 + poll: 0 + + - name: Wait for instance(s) creation to complete + async_status: + jid: "{{ item.ansible_job_id }}" + register: docker_jobs + until: docker_jobs.finished + retries: 300 + with_items: "{{ server.results }}" diff --git a/molecule/local/destroy.yml b/molecule/local/destroy.yml new file mode 100644 index 0000000..3ce7478 --- /dev/null +++ b/molecule/local/destroy.yml @@ -0,0 +1,27 @@ +--- +- name: Destroy + hosts: localhost + connection: local + gather_facts: false + no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}" + vars: + molecule_file: "{{ lookup('env', 'MOLECULE_FILE') }}" + molecule_yml: "{{ lookup('file', molecule_file) | molecule_from_yaml }}" + tasks: + - name: Destroy molecule instance(s) + docker_container: + name: "{{ item.name }}" + state: absent + force_kill: "{{ item.force_kill | default(true) }}" + register: server + with_items: "{{ molecule_yml.platforms }}" + async: 7200 + poll: 0 + + - name: Wait for instance(s) deletion to complete + async_status: + jid: "{{ item.ansible_job_id }}" + register: docker_jobs + until: docker_jobs.finished + retries: 300 + with_items: "{{ server.results }}" diff --git a/molecule/local/molecule.yml b/molecule/local/molecule.yml new file mode 100644 index 0000000..37ba655 --- /dev/null +++ b/molecule/local/molecule.yml @@ -0,0 +1,75 @@ +--- +dependency: + name: galaxy + options: + ignore-certs: True + ignore-errors: True + role-file: requirements.yml +driver: + name: docker +lint: + name: yamllint +platforms: + + - name: ansible_test-01 + image: paulfantom/ubuntu-molecule:16.04 + privileged: True + command: /sbin/init + capabilities: + - SYS_ADMIN + volumes: + - "/sys/fs/cgroup:/sys/fs/cgroup:ro" + groups: + - group1 + + - name: ansible_test-01_2 + image: paulfantom/ubuntu-molecule:18.04 + privileged: True + command: /sbin/init + capabilities: + - SYS_ADMIN + volumes: + - "/sys/fs/cgroup:/sys/fs/cgroup:ro" + groups: + - group1 + + - name: ansible_test-02 + image: ubuntu:trusty + groups: + - groupold +# +# - name: ansible_test-03 +# image: centos/systemd +# command: /sbin/init +# capabilities: +# - SYS_ADMIN +# volumes: +# - "/sys/fs/cgroup:/sys/fs/cgroup:ro" + #privileged: True +# groups: +# - group1 + +provisioner: + name: ansible + config_options: + defaults: + callback_whitelist: profile_tasks + inventory: + group_vars: + master: + burpsrcext: "zip" + burp_version: "master" + burp_remove_clients: + - name: client_to_remove + - name: other_client_to_remove + burp_server_port_per_operation_bool: true + lint: + name: ansible-lint + +scenario: + name: local + +verifier: + name: testinfra + lint: + name: flake8 diff --git a/molecule/local/playbook.yml b/molecule/local/playbook.yml new file mode 100644 index 0000000..a776ae5 --- /dev/null +++ b/molecule/local/playbook.yml @@ -0,0 +1,8 @@ +--- +- name: Converge + hosts: all + roles: + - role: geerlingguy.mysql + - role: ansible-role-nagios + - role: coffeeitworks.ansible_nagios4_server_config + - role: ansible_nagios4_server_thruk \ No newline at end of file diff --git a/molecule/local/prepare.yml b/molecule/local/prepare.yml new file mode 100644 index 0000000..5358b3b --- /dev/null +++ b/molecule/local/prepare.yml @@ -0,0 +1,5 @@ +--- +- name: Prepare + hosts: all + gather_facts: false + tasks: [] diff --git a/molecule/local/tests/test_default.py b/molecule/local/tests/test_default.py new file mode 100644 index 0000000..eedd64a --- /dev/null +++ b/molecule/local/tests/test_default.py @@ -0,0 +1,14 @@ +import os + +import testinfra.utils.ansible_runner + +testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( + os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') + + +def test_hosts_file(host): + f = host.file('/etc/hosts') + + assert f.exists + assert f.user == 'root' + assert f.group == 'root' diff --git a/molecule/local/tests/test_default.pyc b/molecule/local/tests/test_default.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6cb13885d34eb737362538b4b6e3c4c2a62a8450 GIT binary patch literal 1021 zcmdr~&2H2%5FRJnUs3i{pW5|#i`eh>`6t{?ge-! z9)XA9$OFLG*|ep+0ZBX_e;I!>{>I_2t#~}n&e06 zha`P>Jo}ixI+`Zv(ic*ejOJiD4r#ViGS`&KS40UG46Z331G@_tz?Xg*x Date: Sun, 6 Jan 2019 12:49:49 -0300 Subject: [PATCH 02/12] change apt-key installation --- tasks/repositories.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tasks/repositories.yml b/tasks/repositories.yml index f52e69a..a69ed6f 100644 --- a/tasks/repositories.yml +++ b/tasks/repositories.yml @@ -12,9 +12,11 @@ # Add an Apt signing key, uses whichever key is at the URL - name: Install gpg key for thruk repository - shell: 'wget -q "https://labs.consol.de/repo/stable/RPM-GPG-KEY" -O - | sudo apt-key add -' + apt_key: + url: "https://labs.consol.de/repo/stable/RPM-GPG-KEY" + state: present environment: "{{ proxy_env }}" when: add_thruk_repo.changed - name: ensure handlers runs before continue - meta: flush_handlers \ No newline at end of file + meta: flush_handlers From 20dd7acf36c1610adb95246b8889a100dd99aeb7 Mon Sep 17 00:00:00 2001 From: Pablo Estigarribia Date: Sun, 6 Jan 2019 13:10:02 -0300 Subject: [PATCH 03/12] tweaks for molecule tests --- molecule/default/molecule.yml | 9 +++++---- molecule/default/playbook.yml | 1 + molecule/local/playbook.yml | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index c64c09c..262b889 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -33,10 +33,11 @@ platforms: groups: - group1 - - name: ansible_test-02 - image: ubuntu:trusty - groups: - - groupold +# Disable trusty test due to https://github.com/ansible/ansible/issues/21208#event-1883144200 +# - name: ansible_test-02 +# image: ubuntu:trusty +# groups: +# - groupold # # - name: ansible_test-03 # image: centos/systemd diff --git a/molecule/default/playbook.yml b/molecule/default/playbook.yml index 5747ab0..3b9e13f 100644 --- a/molecule/default/playbook.yml +++ b/molecule/default/playbook.yml @@ -1,6 +1,7 @@ --- - name: Converge hosts: all + become: yes roles: - role: geerlingguy.mysql - role: ansible-role-nagios diff --git a/molecule/local/playbook.yml b/molecule/local/playbook.yml index a776ae5..3b9e13f 100644 --- a/molecule/local/playbook.yml +++ b/molecule/local/playbook.yml @@ -1,8 +1,9 @@ --- - name: Converge hosts: all + become: yes roles: - role: geerlingguy.mysql - role: ansible-role-nagios - role: coffeeitworks.ansible_nagios4_server_config - - role: ansible_nagios4_server_thruk \ No newline at end of file + - role: ansible_nagios4_server_thruk From c317a6899f3b579133646e6849604267ceaef40c Mon Sep 17 00:00:00 2001 From: Pablo Estigarribia Date: Sun, 6 Jan 2019 13:15:19 -0300 Subject: [PATCH 04/12] fixes for ubuntu 18.04 and for background copy --- README.md | 7 +++++++ defaults/main.yml | 3 +++ tasks/config_thruk.yml | 1 + vars/Debian.yml | 1 - 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b303a6d..1e1647d 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,13 @@ Thruk interface for nagios. ### To easily replace thruk logo and add backgrounds to panorama view +*Enable var:* + +```yaml +# In your group_vars/thruk_group/vars.yml +thruk_copy_backgrounds: true +``` + Wherever your site.yml (playbook) is, create subfolder: thruk_company_logos, with these files: - logo_thruk.png 246x89 diff --git a/defaults/main.yml b/defaults/main.yml index c8ed0f3..154f5e1 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -4,6 +4,9 @@ thruk_mysql_user: thruk thruk_mysql_password: thruk$1999 thruk_mysql_db: thruk_logs + +# Vars for copying thruk backgrounds +thruk_copy_backgrounds: false thruk_backgrounds_path: '/etc/thruk/usercontent/backgrounds/' diff --git a/tasks/config_thruk.yml b/tasks/config_thruk.yml index 3dfff4f..5416bb8 100644 --- a/tasks/config_thruk.yml +++ b/tasks/config_thruk.yml @@ -11,6 +11,7 @@ mode=666 with_fileglob: - "thruk_backgrounds/*" + when: thruk_copy_backgrounds # Copy your logos to images that will be used by thruk: # It will search for thruk_backgrounds as subfolder where your site.yml is diff --git a/vars/Debian.yml b/vars/Debian.yml index 314594b..403101c 100644 --- a/vars/Debian.yml +++ b/vars/Debian.yml @@ -30,7 +30,6 @@ thruk_dependencies: - php-cli - php-cgi - php-gd - - php-mcrypt - php-sqlite3 - php-pear - pyro From 5f6c2a44190cd97926ab48691fbeda98a2410a01 Mon Sep 17 00:00:00 2001 From: Pablo Estigarribia Date: Sun, 6 Jan 2019 13:40:24 -0300 Subject: [PATCH 05/12] add folders for logos --- files/thruk_backgrounds/readme.txt | 4 ++++ files/thruk_company_logos/readme.txt | 7 +++++++ tasks/config_thruk.yml | 2 ++ 3 files changed, 13 insertions(+) create mode 100644 files/thruk_backgrounds/readme.txt create mode 100644 files/thruk_company_logos/readme.txt diff --git a/files/thruk_backgrounds/readme.txt b/files/thruk_backgrounds/readme.txt new file mode 100644 index 0000000..3213773 --- /dev/null +++ b/files/thruk_backgrounds/readme.txt @@ -0,0 +1,4 @@ +If you want to add images to be used as backgrounds in your panorama view in thruk +you can created a directory "thruk_backgrounds" in same path as your playbook path +(playbook.yml where you call this role). +Then add any image. diff --git a/files/thruk_company_logos/readme.txt b/files/thruk_company_logos/readme.txt new file mode 100644 index 0000000..e8a85fb --- /dev/null +++ b/files/thruk_company_logos/readme.txt @@ -0,0 +1,7 @@ +If you want to replace the logo of thruk. +you can created a directory "thruk_backgrounds_logos" in same path as your playbook path +(playbook.yml where you call this role). +then add: + - logo_thruk.png 246x89 + - logo_thruk_small.png 139x50 + - logo_thruk_mid.png 130x40 diff --git a/tasks/config_thruk.yml b/tasks/config_thruk.yml index 5416bb8..df1ce5b 100644 --- a/tasks/config_thruk.yml +++ b/tasks/config_thruk.yml @@ -28,6 +28,7 @@ mode=644 with_fileglob: - "thruk_company_logos/*" + when: thruk_copy_backgrounds - name: config_thruk | Copy backgrounds to thruk2 theme copy: @@ -38,6 +39,7 @@ mode=644 with_fileglob: - "thruk_company_logos/*" + when: thruk_copy_backgrounds - name: ensure permissions directory to thruk userdata file: From a36c6cd5698ab145cf9357806bb54151d7a5b432 Mon Sep 17 00:00:00 2001 From: Pablo Estigarribia Date: Sun, 6 Jan 2019 13:53:01 -0300 Subject: [PATCH 06/12] fixes on mysql login --- defaults/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/defaults/main.yml b/defaults/main.yml index 154f5e1..d46f7f0 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,8 +1,9 @@ --- # Logcache config for Thruk +mysql_root_password: root thruk_mysql_user: thruk -thruk_mysql_password: thruk$1999 +thruk_mysql_password: thrukpassword thruk_mysql_db: thruk_logs # Vars for copying thruk backgrounds From 6989cd55aa0db35c79028e091d3cfa641faabca3 Mon Sep 17 00:00:00 2001 From: Pablo Estigarribia Date: Sun, 6 Jan 2019 14:00:59 -0300 Subject: [PATCH 07/12] remove python-imaging as dependency --- vars/Debian.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/vars/Debian.yml b/vars/Debian.yml index 403101c..6e3e149 100644 --- a/vars/Debian.yml +++ b/vars/Debian.yml @@ -41,7 +41,6 @@ thruk_dependencies: - libgsf-1-114 - libglib2.0-0 - python-reportlab - - python-imaging - poppler-utils - nagios-images # Installs /usr/share/nagios3/htdocs/images/logos/ From 647e13b09490e467199d7649edc7340789174106 Mon Sep 17 00:00:00 2001 From: Pablo Estigarribia Date: Sun, 6 Jan 2019 14:39:26 -0300 Subject: [PATCH 08/12] adding locales as seems to be required --- vars/Debian-7.yml | 1 + vars/Debian-8.yml | 1 + vars/Debian.yml | 1 + vars/Ubuntu-14.yml | 1 + 4 files changed, 4 insertions(+) diff --git a/vars/Debian-7.yml b/vars/Debian-7.yml index 69d87da..c6b0122 100644 --- a/vars/Debian-7.yml +++ b/vars/Debian-7.yml @@ -49,6 +49,7 @@ thruk_dependencies: - python-imaging - poppler-utils - nagios-images # Installs /usr/share/nagios3/htdocs/images/logos/ + - locales thruk_packages: - thruk # on repository diff --git a/vars/Debian-8.yml b/vars/Debian-8.yml index 69d87da..c6b0122 100644 --- a/vars/Debian-8.yml +++ b/vars/Debian-8.yml @@ -49,6 +49,7 @@ thruk_dependencies: - python-imaging - poppler-utils - nagios-images # Installs /usr/share/nagios3/htdocs/images/logos/ + - locales thruk_packages: - thruk # on repository diff --git a/vars/Debian.yml b/vars/Debian.yml index 6e3e149..abffe24 100644 --- a/vars/Debian.yml +++ b/vars/Debian.yml @@ -43,6 +43,7 @@ thruk_dependencies: - python-reportlab - poppler-utils - nagios-images # Installs /usr/share/nagios3/htdocs/images/logos/ + - locales thruk_packages: - thruk # on repository diff --git a/vars/Ubuntu-14.yml b/vars/Ubuntu-14.yml index 69d87da..c6b0122 100644 --- a/vars/Ubuntu-14.yml +++ b/vars/Ubuntu-14.yml @@ -49,6 +49,7 @@ thruk_dependencies: - python-imaging - poppler-utils - nagios-images # Installs /usr/share/nagios3/htdocs/images/logos/ + - locales thruk_packages: - thruk # on repository From a99cc8f63c0a7e39d397c9cf832b79f0d5c6d4de Mon Sep 17 00:00:00 2001 From: Pablo Estigarribia Date: Mon, 7 Jan 2019 08:43:12 -0300 Subject: [PATCH 09/12] fixes on thruk installation --- defaults/main.yml | 3 +++ tasks/config_thruk.yml | 7 ------- templates/thruk_local.conf.j2 | 2 +- vars/Debian-7.yml | 1 + vars/Debian-8.yml | 1 + vars/Debian.yml | 1 + vars/Ubuntu-14.yml | 1 + 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index d46f7f0..37e71dd 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -26,6 +26,9 @@ thruk_report_include_class2: 0 # First day of week: 1 (Monday) thruk_first_day_of_week: 1 +# https://www.thruk.org/documentation/configuration.html#report_use_temp_files +thruk_report_use_temp_files: 7 + # Theme change: thruk_default_theme: Thruk2 # color complete status line with status colour or just the status diff --git a/tasks/config_thruk.yml b/tasks/config_thruk.yml index df1ce5b..1ca43eb 100644 --- a/tasks/config_thruk.yml +++ b/tasks/config_thruk.yml @@ -60,13 +60,6 @@ dest=/etc/thruk/cgi.cfg owner=root group=root mode=644 -- name: configure web thruk - template: - src=apache2/thruk.conf.j2 - dest=/etc/apache2/conf-available/thruk.conf - owner=root group=root mode=644 - notify: Reload Apache - - name: configure thruk template: src=thruk_local.conf.j2 diff --git a/templates/thruk_local.conf.j2 b/templates/thruk_local.conf.j2 index ce42673..42d6340 100644 --- a/templates/thruk_local.conf.j2 +++ b/templates/thruk_local.conf.j2 @@ -7,7 +7,7 @@ default_theme = {{ thruk_default_theme }} # For more efficient reports: -report_use_temp_files = 31 +report_use_temp_files = {{ thruk_report_use_temp_files }} report_update_logcache = {{ thruk_report_update_logcache }} # allow error reports diff --git a/vars/Debian-7.yml b/vars/Debian-7.yml index c6b0122..edd3e5f 100644 --- a/vars/Debian-7.yml +++ b/vars/Debian-7.yml @@ -15,6 +15,7 @@ thruk_dependencies: - dialog - graphviz - libapache2-mod-fcgid + - libapache2-mod-fastcgi - libapache2-mod-proxy-html - apache2-mpm-prefork - apache2-utils diff --git a/vars/Debian-8.yml b/vars/Debian-8.yml index c6b0122..edd3e5f 100644 --- a/vars/Debian-8.yml +++ b/vars/Debian-8.yml @@ -15,6 +15,7 @@ thruk_dependencies: - dialog - graphviz - libapache2-mod-fcgid + - libapache2-mod-fastcgi - libapache2-mod-proxy-html - apache2-mpm-prefork - apache2-utils diff --git a/vars/Debian.yml b/vars/Debian.yml index abffe24..efcbbfd 100644 --- a/vars/Debian.yml +++ b/vars/Debian.yml @@ -15,6 +15,7 @@ thruk_dependencies: - dialog - graphviz - libapache2-mod-fcgid + - libapache2-mod-fastcgi - apache2-utils - libdbi1 - libevent-1.4-2 diff --git a/vars/Ubuntu-14.yml b/vars/Ubuntu-14.yml index c6b0122..edd3e5f 100644 --- a/vars/Ubuntu-14.yml +++ b/vars/Ubuntu-14.yml @@ -15,6 +15,7 @@ thruk_dependencies: - dialog - graphviz - libapache2-mod-fcgid + - libapache2-mod-fastcgi - libapache2-mod-proxy-html - apache2-mpm-prefork - apache2-utils From f744b26d0767417e98aa68fd8acf8ffb0e24dd41 Mon Sep 17 00:00:00 2001 From: Pablo Estigarribia Date: Mon, 7 Jan 2019 09:31:33 -0300 Subject: [PATCH 10/12] add modules to enable on apache2 --- tasks/config_thruk.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tasks/config_thruk.yml b/tasks/config_thruk.yml index 1ca43eb..bbb50ed 100644 --- a/tasks/config_thruk.yml +++ b/tasks/config_thruk.yml @@ -73,3 +73,15 @@ - { src: '/usr/share/nagios3/htdocs/images/logos', dest: '/usr/share/thruk/themes/themes-available/Exfoliation/images/logos' } - { src: '/usr/share/nagios3/htdocs/images/logos', dest: '/usr/share/thruk/themes/themes-available/Thruk2/images/logos' } when: ansible_os_family == 'Debian' + +# enables the Apache2 module "fastcgi" +- name: enable fastcgi on apache for thruk installation + apache2_module: + state: present + name: fastcgi + +# enables the Apache2 module "fcgid" +- name: enable fastcgi on apache for thruk installation + apache2_module: + state: present + name: fcgid From a299de8777c8ff216ed5cf6c4e038517f8120aa6 Mon Sep 17 00:00:00 2001 From: Pablo Estigarribia Date: Mon, 7 Jan 2019 09:32:40 -0300 Subject: [PATCH 11/12] fastcgi not available on ubuntu18 --- vars/Ubuntu-18.yml | 49 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 vars/Ubuntu-18.yml diff --git a/vars/Ubuntu-18.yml b/vars/Ubuntu-18.yml new file mode 100644 index 0000000..abffe24 --- /dev/null +++ b/vars/Ubuntu-18.yml @@ -0,0 +1,49 @@ +--- +# Thruk repository + +thruk_apt_sources: + - "deb http://labs.consol.de/repo/stable/ubuntu {{ ansible_distribution_release }} main" + +# Check_mk dependencies + +thruk_dependencies: + - debconf + - time + - traceroute + - libsnmp-python + - curl + - dialog + - graphviz + - libapache2-mod-fcgid + - apache2-utils + - libdbi1 + - libevent-1.4-2 + - libltdl7 + - libpango1.0-0 + - libperl-dev + - libreadline5 + - libuuid1 + - libxml2 + - patch + - rpm + - binutils + - php-cli + - php-cgi + - php-gd + - php-sqlite3 + - php-pear + - pyro + - rsync + - lcab + - unzip + - python-ldap + - libpcap0.8 + - libgsf-1-114 + - libglib2.0-0 + - python-reportlab + - poppler-utils + - nagios-images # Installs /usr/share/nagios3/htdocs/images/logos/ + - locales + +thruk_packages: + - thruk # on repository From d351b0411e68164de3ff499e2c679c0434dfb7d0 Mon Sep 17 00:00:00 2001 From: Pablo Estigarribia Date: Mon, 7 Jan 2019 11:45:35 -0300 Subject: [PATCH 12/12] more fixes for ubuntu 16 and 18 --- molecule/local/molecule.yml | 28 ++++++++++++++-------------- tasks/config_thruk.yml | 8 ++++++-- tasks/install_thruk.yml | 4 +++- tasks/tests.yml | 8 +++++++- tasks/thruk_fixes.yml | 8 +++++++- vars/Debian.yml | 3 +++ vars/RedHat.yml | 3 +++ vars/Ubuntu-18.yml | 3 +++ 8 files changed, 46 insertions(+), 19 deletions(-) diff --git a/molecule/local/molecule.yml b/molecule/local/molecule.yml index 37ba655..bd58863 100644 --- a/molecule/local/molecule.yml +++ b/molecule/local/molecule.yml @@ -22,21 +22,21 @@ platforms: groups: - group1 - - name: ansible_test-01_2 - image: paulfantom/ubuntu-molecule:18.04 - privileged: True - command: /sbin/init - capabilities: - - SYS_ADMIN - volumes: - - "/sys/fs/cgroup:/sys/fs/cgroup:ro" - groups: - - group1 +# - name: ansible_test-01_2 +# image: paulfantom/ubuntu-molecule:18.04 +# privileged: True +# command: /sbin/init +# capabilities: +# - SYS_ADMIN +# volumes: +# - "/sys/fs/cgroup:/sys/fs/cgroup:ro" +# groups: +# - group1 - - name: ansible_test-02 - image: ubuntu:trusty - groups: - - groupold +# - name: ansible_test-02 +# image: ubuntu:trusty +# groups: +# - groupold # # - name: ansible_test-03 # image: centos/systemd diff --git a/tasks/config_thruk.yml b/tasks/config_thruk.yml index bbb50ed..3cd75e7 100644 --- a/tasks/config_thruk.yml +++ b/tasks/config_thruk.yml @@ -65,7 +65,9 @@ src=thruk_local.conf.j2 dest=/etc/thruk/thruk_local.conf owner=www-data group=www-data mode=660 - notify: Restart Thruk + notify: + - Restart Apache + - Restart Thruk - name: link images/logos for thruk theme Exfoliation file: src={{ item.src }} dest={{ item.dest }} state=link @@ -79,9 +81,11 @@ apache2_module: state: present name: fastcgi + when: thruk_enable_fastcgi # enables the Apache2 module "fcgid" -- name: enable fastcgi on apache for thruk installation +- name: enable fcgid on apache for thruk installation apache2_module: state: present name: fcgid + diff --git a/tasks/install_thruk.yml b/tasks/install_thruk.yml index 8dcbddf..829f5d7 100644 --- a/tasks/install_thruk.yml +++ b/tasks/install_thruk.yml @@ -9,4 +9,6 @@ - name: Install thruk packages package: name={{ thruk_packages| join(',') }} state=present environment: - DEBIAN_FRONTEND: noninteractive \ No newline at end of file + DEBIAN_FRONTEND: noninteractive + notify: Restart Apache + diff --git a/tasks/tests.yml b/tasks/tests.yml index a75364d..b52d722 100644 --- a/tasks/tests.yml +++ b/tasks/tests.yml @@ -11,4 +11,10 @@ state: started - name: test if "{{ nagios_live_sock }}" exist for thruk connection - file: path="{{ nagios_live_sock }}" state=file \ No newline at end of file + file: path="{{ nagios_live_sock }}" state=file + +- name: ensure thruk is started + service: + name: "thruk" + state: started + diff --git a/tasks/thruk_fixes.yml b/tasks/thruk_fixes.yml index 242da5e..31a55fc 100644 --- a/tasks/thruk_fixes.yml +++ b/tasks/thruk_fixes.yml @@ -3,4 +3,10 @@ - name: delete /etc/apache2/conf-enabled/thruk_cookie_auth_vhost.conf fixes https://github.com/sni/Thruk/issues/504 file: path='/etc/apache2/conf-enabled/thruk_cookie_auth_vhost.conf' state=absent - notify: Reload Apache \ No newline at end of file + notify: Restart Apache + +- name: ensure /usr/share/thruk/var exists + file: + path: /usr/share/thruk/var + state: directory + diff --git a/vars/Debian.yml b/vars/Debian.yml index efcbbfd..11e55bd 100644 --- a/vars/Debian.yml +++ b/vars/Debian.yml @@ -48,3 +48,6 @@ thruk_dependencies: thruk_packages: - thruk # on repository + +thruk_enable_fastcgi: true + diff --git a/vars/RedHat.yml b/vars/RedHat.yml index e36daab..7b004a9 100644 --- a/vars/RedHat.yml +++ b/vars/RedHat.yml @@ -5,3 +5,6 @@ thruk_dependencies: thruk_packages: - thruk # on repository + +thruk_enable_fastcgi: false + diff --git a/vars/Ubuntu-18.yml b/vars/Ubuntu-18.yml index abffe24..7dc63d3 100644 --- a/vars/Ubuntu-18.yml +++ b/vars/Ubuntu-18.yml @@ -47,3 +47,6 @@ thruk_dependencies: thruk_packages: - thruk # on repository + +thruk_enable_fastcgi: false +