Skip to content
Snippets Groups Projects
Commit 2c42752b authored by nimrod's avatar nimrod
Browse files

- Forked from the example role.

parent ddb6c3eb
No related branches found
No related tags found
No related merge requests found
Example
#######
Syslog forwarding
#################
An (empty) example Ansible role complete with working tests out of the box. For
more information read the `blog post
<https://www.shore.co.il/blog/ansible-example-role/>`_.
Configure syslog forwarding (syslogd on OpenBSD, rsyslog on Debian).
Requirements
------------
......
---
# defaults file for ansible-role-example
# defaults file for ansible-role-syslog-forward
syslog_server:
---
# handlers file for ansible-role-example
# handlers file for ansible-role-syslog-forward
- name: Restart rsyslog
service:
name: rsyslog
state: restarted
- name: Restart syslogd
service:
name: syslogd
state: restarted
galaxy_info:
author: Nimrod Adar
description: An example Ansible role
description: Configure syslog forwarding.
company: Shore technologies
license: MIT
min_ansible_version: 2.0
......@@ -8,8 +8,8 @@ galaxy_info:
- name: OpenBSD
versions:
- 5.9
galaxy_tags: [ ansible ]
dependencies:
- src: https://www.shore.co.il/git/ansible-role-openbsd-bootstrap
scm: git
name: bootstrap
- name: Debian
versions:
- jessie
galaxy_tags: [ syslog ]
dependencies: []
......@@ -15,8 +15,10 @@ vagrant:
platforms:
- name: openbsd
box: kaorimatz/openbsd-5.9-amd64
- name: debian
box: debian/jessie64
instances:
- name: ansible-role-example
- name: ansible-role-syslog-forward
options:
append_platform_to_hostname: yes
raw_config_args:
......
---
# tasks file for ansible-role-example
# tasks file for ansible-role-syslog-forward
- assert:
that:
- ansible_os_family == 'OpenBSD'
- ansible_distribution_release == '5.9'
- name: Assert
assert:
that: ansible_os_family in [ 'Debian', 'OpenBSD' ]
- name: APT install rsyslog
when: ansible_os_family == 'Debian'
apt:
name: rsyslog-gnutls
state: present
update_cache: yes
cache_valid_time: 3600
- name: Configure rsyslog forwarding
when: ansible_os_family == 'Debian'
template:
src: forwarding.conf.j2
dest: /etc/rsyslog.d/forwarding.conf
owner: root
group: root
mode: 0o0644
notify:
- Restart rsyslog
- name: Configure syslogd forwarding
when: ansible_os_family == 'OpenBSD'
lineinfile:
dest: /etc/syslog.conf
line: '*.* @tls://{{ syslog_server}}'
regexp: '^\*.\* '
state: present
notify:
- Restart syslogd
{#
$DefaultNetstreamDriver gtls
$DefaultNetstreamDriverCAFile {{ tls_ca_cert_path }}
$DefaultNetstreamDriverCertFile {{ tls_cert_path }}
$DefaultNetstreamDriverKeyFile {{ tls_key_path }}
$ActionSendStreamDriverAuthMode x509/name
#}
$ActionSendStreamDriverPermittedPeer {{ syslog_server }}
$ActionSendStreamDriverMode 1
*.* @@{{ syslog_server }}
def test_syslog_forward(Service, SystemInfo):
if SystemInfo.type == 'openbsd':
assert Service('syslogd').is_running
if SystemInfo.type == 'linux' and SystemInfo.distribution == 'debian'
elif SystemInfo.type == 'linux' and SystemInfo.distribution in ['debian',
'ubuntu']:
assert Service('rsyslog').is_running
---
# vars file for ansible-role-example
# vars file for ansible-role-syslog-forward
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment