diff --git a/ansible/2022-08-17.csv b/ansible/2022-08-17.csv new file mode 100644 index 0000000..ed86e8a --- /dev/null +++ b/ansible/2022-08-17.csv @@ -0,0 +1,19 @@ +vlearning-db001-tst.infolegale.net;Debian;10;0;5 +app-db001-tst.infolegale.net;Debian;10;0;9 +consults-db001-tst.infolegale.net;Debian;10;0;147 +vador-db001-tst.infolegale.net;Debian;10;0;147 +tlearning-db003-tst.infolegale.net;Ubuntu;18.04;0;308 +transdb-db001-tst.infolegale.net;Debian;10;0;147 +mysql8-db001-tst.infolegale.net;Debian;11;3;119 +mongo-db001-tst.infolegale.net;Ubuntu;20.04;0;28 +orchestrator-mgr001-tst.infolegale.net;Ubuntu;20.04;0;28 +redis5-db001-tst.infolegale.net;Debian;10;0;326 +redis-db001-tst.infolegale.net;Ubuntu;18.04;0;326 +docker-hpv001-tst.infolegale.net;Ubuntu;20.04;0;106 +docker-hpv002-tst.infolegale.net;Ubuntu;20.04;0;398 +docker-hpv004-tst.infolegale.net;Ubuntu;20.04;0;28 +rundeck-sch001-tst.infolegale.net;Debian;10;0;91 +docker-hpv003-tst.infolegale.net;Ubuntu;20.04;0;125 +proxysql-db001-tst.infolegale.net;Ubuntu;20.04;0;475 +docker-hpv005-tst.infolegale.net;Ubuntu;20.04;0;119 +docker-hpv006-tst.infolegale.net;Ubuntu;20.04;0;309 diff --git a/ansible/ansible.cfg b/ansible/ansible.cfg new file mode 100644 index 0000000..64fe4aa --- /dev/null +++ b/ansible/ansible.cfg @@ -0,0 +1,12 @@ +[defaults] +vault_password_file = ~/.vault_password +roles_path = roles +interpreter_python = auto +callback_plugins = ./hooks/ +fact_caching = jsonfile +fact_caching_connection = ~/.cache/ansible/ +deprecation_warnings=False +[hashi_vault_collection] +url = "https://vault.infolegale.net" +token_file = .vault-token +token_validate = None diff --git a/ansible/hooks/__pycache__/update_dashboard.cpython-38.pyc b/ansible/hooks/__pycache__/update_dashboard.cpython-38.pyc new file mode 100644 index 0000000..dac381c Binary files /dev/null and b/ansible/hooks/__pycache__/update_dashboard.cpython-38.pyc differ diff --git a/ansible/hooks/update_dashboard.py b/ansible/hooks/update_dashboard.py new file mode 100644 index 0000000..19e2d7c --- /dev/null +++ b/ansible/hooks/update_dashboard.py @@ -0,0 +1,23 @@ +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +from ansible.plugins.callback import CallbackBase + + +class CallbackModule(CallbackBase): + + CALLBACK_VERSION = 2.0 + CALLBACK_TYPE = 'stdout' + CALLBACK_NAME = 'update_dashboard' + + def v2_runner_on_ok(self, result): + if result._task.action == 'debug': + ansible_msg = result._result.get('msg', None) + if ansible_msg: + print(ansible_msg) + + def v2_runner_on_unreachable(self, result): + print("%s;UNREACHABLE" % result._host.get_name()) + + def v2_runner_on_failed(self, result, ignore_errors=False): + print("%s;FAILED" % result._host.get_name()) diff --git a/ansible/hosts-tst b/ansible/hosts-tst new file mode 100644 index 0000000..860a0a4 --- /dev/null +++ b/ansible/hosts-tst @@ -0,0 +1,44 @@ +########## +# VARS +########## +[all:vars] +env='tst' +symfony_env="recette" +vmpass='$6$oIJS8mHoKPJVXZIR$fQVPI7.M9/3wD6O.8JS5iYIL6v0tx3BfmiHKIeb/h88yL9R9GYsGJnePK9UEoBZ2F8AfZhwHGRvV3iv9CGChV.' +relayhost='maildump.infolegale.net' +scriptsToSupervise=[['borg-backup.sh','129600']] +graylogapp="graylog-log001-stg.infolegale.net:12201" +cmk_server_ip="10.12.251.1" + +[mysql] +tlearning-db003-tst.infolegale.net +vlearning-db001-tst.infolegale.net +app-db001-tst.infolegale.net +consults-db001-tst.infolegale.net +vador-db001-tst.infolegale.net +transdb-db001-tst.infolegale.net +mysql8-db001-tst.infolegale.net + +[mongo] +mongo-db001-tst.infolegale.net + +[mgr] +orchestrator-mgr001-tst.infolegale.net + +[redis] +redis-db001-tst.infolegale.net +redis5-db001-tst.infolegale.net + +[docker] +docker-hpv001-tst.infolegale.net +docker-hpv002-tst.infolegale.net +docker-hpv003-tst.infolegale.net +docker-hpv004-tst.infolegale.net +docker-hpv005-tst.infolegale.net +docker-hpv006-tst.infolegale.net + +[proxysql] +proxysql-db001-tst.infolegale.net + +[rundeck] +rundeck-sch001-tst.infolegale.net diff --git a/ansible/auto-updates-result.yml b/ansible/playbooks/auto-updates-result.yml similarity index 100% rename from ansible/auto-updates-result.yml rename to ansible/playbooks/auto-updates-result.yml diff --git a/ansible/main.yml b/ansible/playbooks/main.yml similarity index 65% rename from ansible/main.yml rename to ansible/playbooks/main.yml index c09cec6..bf2f874 100644 --- a/ansible/main.yml +++ b/ansible/playbooks/main.yml @@ -27,25 +27,6 @@ tags: - skip_ansible_lint - - # - ## Debian / RedHat hosts ## - # - - # get auto-updates script status - - include: auto-updates-result.yml - when: "'auto_updates' in group_names and - ((ansible_os_family == 'RedHat' and ansible_distribution_major_version|int >= 6) or - (ansible_os_family == 'Debian' and ansible_distribution_major_version|int >= 8))" - - - name: set status if not in auto-updates - set_fact: auto_updates_status=NA - when: "'auto_updates' not in group_names or - (ansible_os_family == 'RedHat' and ansible_distribution_major_version|int < 6) or - (ansible_os_family == 'Debian' and ansible_distribution_major_version|int < 8)" - - ## Debian - # get number of updates and debug - name: (debian) update apt cache if older than 1 day apt: update_cache=yes cache_valid_time=86400 @@ -58,9 +39,9 @@ when: update_cache_result is succeeded - name: (Debian) output - debug: msg="{{ inventory_hostname }};{{ ansible_distribution }};{{ ansible_distribution_major_version }};{{ available_updates.stdout | default('') }};{{ uptime.stdout }};{{ auto_updates_status | default('UNK')}}" + debug: msg="{{ inventory_hostname }};{{ ansible_distribution }};{{ ansible_distribution_major_version }};{{ available_updates.stdout | default('') }};{{ uptime.stdout }}" when: ansible_distribution == "Debian" - name: (Ubuntu) output - debug: msg="{{ inventory_hostname }};{{ ansible_distribution }};{{ ansible_distribution_version }};{{ available_updates.stdout | default('') }};{{ uptime.stdout }};{{ auto_updates_status | default('UNK')}}" + debug: msg="{{ inventory_hostname }};{{ ansible_distribution }};{{ ansible_distribution_version }};{{ available_updates.stdout | default('') }};{{ uptime.stdout }}" when: ansible_distribution == "Ubuntu" diff --git a/ansible/packages.yml b/ansible/playbooks/packages.yml similarity index 89% rename from ansible/packages.yml rename to ansible/playbooks/packages.yml index d0de86a..d6e3c53 100644 --- a/ansible/packages.yml +++ b/ansible/playbooks/packages.yml @@ -9,28 +9,23 @@ - apt - apache2 - bash - - dnsmasq - - exim - - httpd + - check-mk-agent + - elasticsearch - libc-bin - - mailx - make - - mariadb-server - - memcached - mysql-server - - nagios - nginx - - nrpe - openssh-server - php5 - php7.0 - php7.1 - php7.2 - php7.4 - - phpmyadmin - postfix + - proxysql - redis - redis-server + - sphinxsearch - sudo - systemd diff --git a/ansible/packages_include.yml b/ansible/playbooks/packages_include.yml similarity index 100% rename from ansible/packages_include.yml rename to ansible/playbooks/packages_include.yml