back to singular
This commit is contained in:
61
roles/database/tasks/configure_snmpd.yml
Normal file
61
roles/database/tasks/configure_snmpd.yml
Normal file
@@ -0,0 +1,61 @@
|
||||
- name: database | snmpd | get script
|
||||
get_url:
|
||||
url: "https://github.com/librenms/librenms-agent/raw/master/snmp/postgres"
|
||||
dest: "/etc/snmp/postgres"
|
||||
mode: "0755"
|
||||
owner: "root"
|
||||
group: "root"
|
||||
when: postgres == true
|
||||
register: postgres_script
|
||||
|
||||
- name: database | snmpd | modify script part 1
|
||||
lineinfile:
|
||||
path: "/etc/snmp/postgres"
|
||||
regexp: "^\$cpg -u $DBuser --action dbstats | awk -F ' ' '$"
|
||||
state: present
|
||||
line: "$cpg --action dbstats | awk -F ' ' '"
|
||||
when: postgres_script.rc == 0
|
||||
|
||||
- name: database | snmpd | modify script part 2
|
||||
replace:
|
||||
path: "/etc/snmp/postgres"
|
||||
regexp: "\\:"
|
||||
replace: ":"
|
||||
when: postgres_script.rc == 0
|
||||
|
||||
- include_tasks: install_check_postgres.yml
|
||||
when: postgres == true
|
||||
|
||||
- name: database | snmpd | get script
|
||||
get_url:
|
||||
url: "https://github.com/librenms/librenms-agent/raw/master/snmp/mysql"
|
||||
dest: "/etc/snmp/mysql"
|
||||
mode: "0755"
|
||||
owner: "root"
|
||||
group: "root"
|
||||
when: mysql == true
|
||||
|
||||
- name: database | snmpd | create configuration
|
||||
template:
|
||||
src: "mysql.cnf.j2"
|
||||
dest: "/etc/snmp/mysql.cnf"
|
||||
mode: "0644"
|
||||
when: mysql == true
|
||||
|
||||
- name: database | snmpd | configure extend
|
||||
lineinfile:
|
||||
path: "{{ snmpd_conf }}"
|
||||
state: present
|
||||
line: "extend postgres {{ sudo }} -u postgres /etc/snmp/postgres"
|
||||
insertafter: "# SECTION: Extends"
|
||||
notify: restart_snmpd
|
||||
when: postgres == true
|
||||
|
||||
- name: database | snmpd | configure extend
|
||||
lineinfile:
|
||||
path: "{{ snmpd_conf }}"
|
||||
state: present
|
||||
line: "extend mysql /etc/snmp/mysql"
|
||||
insertafter: "# SECTION: Extends"
|
||||
notify: restart_snmpd
|
||||
when: mysql == true
|
||||
23
roles/database/tasks/install_check_postgres.yml
Normal file
23
roles/database/tasks/install_check_postgres.yml
Normal file
@@ -0,0 +1,23 @@
|
||||
- name: database | snmpd | get script
|
||||
git:
|
||||
repo: "https://github.com/bucardo/check_postgres.git"
|
||||
dest: "~/check_postgres"
|
||||
|
||||
- name: database | snmpd | prepare script
|
||||
command:
|
||||
cmd: "perl Makefile.PL"
|
||||
creates: "~/check_postgres/Makefile"
|
||||
chdir: "~/check_postgres"
|
||||
|
||||
- name: database | snmpd | build script
|
||||
command:
|
||||
cmd: "make"
|
||||
chdir: "~/check_postgres"
|
||||
creates: "~/check_postgres/pm_to_blib"
|
||||
|
||||
- name: database | snmpd | install script
|
||||
command:
|
||||
cmd: "make install"
|
||||
chdir: "~/check_postgres"
|
||||
creates: "/usr/local/bin/check_postgres.pl"
|
||||
become: true
|
||||
2
roles/database/tasks/install_mysql.yml
Normal file
2
roles/database/tasks/install_mysql.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
- debug:
|
||||
msg: "mysql: {{ mysql }}"
|
||||
9
roles/database/tasks/install_postgres.yml
Normal file
9
roles/database/tasks/install_postgres.yml
Normal file
@@ -0,0 +1,9 @@
|
||||
- name: database | postgres | install postgres packages
|
||||
package:
|
||||
name: "{{ item.package }}"
|
||||
update_cache: yes
|
||||
cache_valid_time: 3600
|
||||
state: latest
|
||||
install_recommends: no
|
||||
become: yes
|
||||
with_items: "{{ postgres_pkgs.packages }}"
|
||||
9
roles/database/tasks/install_redis.yml
Normal file
9
roles/database/tasks/install_redis.yml
Normal file
@@ -0,0 +1,9 @@
|
||||
- name: database | redis | install redis packages
|
||||
package:
|
||||
name: "{{ item.package }}"
|
||||
update_cache: yes
|
||||
cache_valid_time: 3600
|
||||
state: latest
|
||||
install_recommends: no
|
||||
become: yes
|
||||
with_items: "{{ redis_pkgs.packages }}"
|
||||
17
roles/database/tasks/main.yml
Normal file
17
roles/database/tasks/main.yml
Normal file
@@ -0,0 +1,17 @@
|
||||
# Load distro-specific variables
|
||||
- include_vars: "{{ ansible_distribution|lower }}.yml"
|
||||
tags: always
|
||||
ignore_errors: True
|
||||
|
||||
- block:
|
||||
- debug:
|
||||
msg: "mysql: {{ mysql }}"
|
||||
# install software
|
||||
- import_tasks: install_mysql.yml
|
||||
when:
|
||||
- mysql is defined
|
||||
- mysql == true
|
||||
- import_tasks: install_postgres.yml
|
||||
when: postgres == true
|
||||
- import_tasks: install_redis.yml
|
||||
when: redis == true
|
||||
12
roles/database/vars/debian.yml
Normal file
12
roles/database/vars/debian.yml
Normal file
@@ -0,0 +1,12 @@
|
||||
redis_pkgs:
|
||||
packages:
|
||||
- package: "redis-server"
|
||||
- package: "redis-tools"
|
||||
|
||||
postgres_pkgs:
|
||||
packages:
|
||||
- package: "libpq-dev"
|
||||
- package: "postgresql"
|
||||
- package: "postgresql-contrib"
|
||||
- package: "python3-psycopg2"
|
||||
- package: "sudo"
|
||||
12
roles/database/vars/ubuntu.yml
Normal file
12
roles/database/vars/ubuntu.yml
Normal file
@@ -0,0 +1,12 @@
|
||||
redis_pkgs:
|
||||
packages:
|
||||
- package: "redis-server"
|
||||
- package: "redis-tools"
|
||||
|
||||
postgres_pkgs:
|
||||
packages:
|
||||
- package: "libpq-dev"
|
||||
- package: "postgresql"
|
||||
- package: "postgresql-contrib"
|
||||
- package: "python3-psycopg2"
|
||||
- package: "sudo"
|
||||
Reference in New Issue
Block a user