|
# more or less as per http://wiki.znc.in/Running_ZNC_as_a_system_daemon
|
|
|
|
- name: Install znc dependencies
|
|
apt: pkg={{ item }} state=installed
|
|
with_items:
|
|
- automake
|
|
- build-essential
|
|
- checkinstall
|
|
- g++
|
|
- libperl-dev
|
|
- libsasl2-dev
|
|
- libssl-dev
|
|
- libtool
|
|
- openssl
|
|
- pkg-config
|
|
- python3-dev
|
|
- swig
|
|
|
|
- name: Download znc release
|
|
get_url: url=http://znc.in/releases/archive/znc-{{ znc_version }}.tar.gz dest=/root/znc-{{ znc_version }}.tar.gz
|
|
|
|
- name: Decompress znc source
|
|
command: tar xzf /root/znc-{{ znc_version }}.tar.gz chdir=/root creates=/root/znc-{{ znc_version }}/configure
|
|
|
|
- name: Build and install znc
|
|
shell: ./configure --enable-python && make && make install executable=/bin/bash chdir=/root/znc-{{ znc_version }} creates=/usr/local/bin/znc
|
|
notify: restart znc
|
|
|
|
- name: Create znc group
|
|
group: name=znc state=present
|
|
|
|
- name: Create znc user
|
|
user: name=znc state=present home=/var/lib/znc system=yes group=znc shell=/usr/sbin/nologin
|
|
|
|
- name: Copy znc init file into place
|
|
copy: src=etc_init.d_znc dest=/etc/init.d/znc mode=0755
|
|
|
|
- name: create self-signed SSL cert
|
|
command: openssl req -new -nodes -x509 -subj "/C=FR/ST=SomeWhere/L=OverTheRainBow/O=znc/CN=znc.{{ domain }}" -days 3650 -keyout /root/znc.key -out /root/znc.crt -extensions v3_ca creates=/root/znc.crt
|
|
notify: restart znc
|
|
|
|
- name: create self-signed SSL cert-2
|
|
shell: cat /root/znc.crt > /var/lib/znc/znc.pem && cat /root/znc.crt >> /root/znc.key
|
|
|
|
- name: Ensure znc user and group can read cert
|
|
file: path=/var/lib/znc/znc.pem group=znc owner=znc mode=640
|
|
notify: restart znc
|
|
|
|
- name: Check for existing config file
|
|
command: cat /var/lib/znc/configs/znc.conf
|
|
register: znc_config
|
|
ignore_errors: True
|
|
changed_when: False # never report as "changed"
|
|
|
|
- name: Create znc config directory
|
|
file: state=directory path=/var/lib/znc/configs group=znc owner=znc
|
|
|
|
- name: Copy znc configuration file into place
|
|
template: src=var_lib_znc_configs_znc.conf.j2 dest=/var/lib/znc/configs/znc.conf owner=znc group=znc
|
|
when: znc_config.rc != 0
|
|
notify: restart znc
|
|
|
|
- name: Ensure znc is a system service
|
|
service: name=znc state=started enabled=true
|