diff --git a/Makefile b/Makefile index 7413eaff7f0a230fa33b82431f293b89e900a3ad..2a7c838ee5ec2869a988d6d5671097b9bdd9c975 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,7 @@ open_all: ${EDITOR} .gitignore inv* Makefile README.md ${EDITOR} tasks/*.yml ${EDITOR} tasks/files/sshd_config + ${EDITOR} tasks/templates/*.j2 ${EDITOR} tasks/system_cfg/*.yml ${EDITOR} tasks/system_cfg/templates/*.j2 ${EDITOR} tasks/user_cfg/*.yml diff --git a/inventory.sample b/inventory.sample index 1190cb679ed78e7156770cf3f0839ca921bd61bc..2828b709f2a56e2c080ee15b2715ecdadb5ff4f0 100644 --- a/inventory.sample +++ b/inventory.sample @@ -20,3 +20,7 @@ timezone="UTC" [workstation:vars] timezone="Europe/Paris" + +[all:vars] +ldp_token="put-yours-here" +ldp_zone="put-yours-here" diff --git a/tasks/ldp.yml b/tasks/ldp.yml new file mode 100644 index 0000000000000000000000000000000000000000..c8e06b825af410374dc53ad673fd9bc88dd86d60 --- /dev/null +++ b/tasks/ldp.yml @@ -0,0 +1,28 @@ +--- +- hosts: "{{ host_list }}" + remote_user: root + + tasks: + - name: LDP | install packages + ansible.builtin.apt: + cache_valid_time: 3600 + force_apt_get: yes + pkg: + - syslog-ng + - ca-certificates + state: present + update_cache: true + + - name: LDP | syslog-ng config + ansible.builtin.template: + src: templates/ldp.conf.j2 + dest: "/etc/syslog-ng/conf.d/ldp.conf" + mode: 0640 + owner: root + group: root + + - name: LDP | restart syslog-ng deamon + ansible.builtin.systemd: + state: restarted + daemon_reload: yes + name: syslog-ng diff --git a/tasks/templates/ldp.conf.j2 b/tasks/templates/ldp.conf.j2 new file mode 100644 index 0000000000000000000000000000000000000000..61193533f832edd7dcac8d6c3338bc635fda3f5e --- /dev/null +++ b/tasks/templates/ldp.conf.j2 @@ -0,0 +1,32 @@ +template ovhTemplate { + # Source: https://docs.ovh.com/fr/logs-data-platform/how-to-log-your-linux/ + + template("<${LEVEL_NUM}>1 ${ISODATE} ${HOST} ${PROGRAM} ${PID} - [sdid@32473 X-OVH-TOKEN=\"{{ ldp_token }}\" pid=\"${PID}\" facility=\"${FACILITY}\" priority=\"${PRIORITY}\"] ${MSG}\n"); + template_escape(no); +}; + +destination ovhPaaSLogs { + network("{{ ldp_zone }}.logs.ovh.com" + port(6514), + template(ovhTemplate), + ts_format("iso"), + transport("tls"), + tls(peer-verify("required-trusted") ca_dir("/etc/ssl/certs/")), + keep-alive(yes), + so_keepalive(yes), + ); +}; + +destination localfile { + file("/var/log/temporaryfiletochecklogs.log"); +}; + +log { + source(s_src); + destination(ovhPaaSLogs); +}; + +log { + source(s_src); + destination(localfile); +};