110 lines
4.1 KiB
YAML
110 lines
4.1 KiB
YAML
|
- name: Configure solanum on routers
|
||
|
hosts: routers
|
||
|
remote_user: root
|
||
|
tasks:
|
||
|
- name: See if solanum has been built already
|
||
|
ansible.builtin.stat:
|
||
|
path: /home/solanum/ircd
|
||
|
register: solanum_already_built
|
||
|
- name: Add Debian build dependencies
|
||
|
ansible.builtin.package:
|
||
|
name: automake,autotools-dev,bsdextrautils,build-essential,byacc,curl,flex,git,libsqlite3-dev,libssl-dev,libtool,make,pkg-config,sqlite3
|
||
|
state: present
|
||
|
when: ansible_distribution == 'Debian' and solanum_already_built.stat.exists == False
|
||
|
- name: Add Arch build dependencies
|
||
|
ansible.builtin.pacman:
|
||
|
name: base-devel,autoconf,automake,libtool
|
||
|
state: present
|
||
|
when: ansible_distribution == 'Archlinux' and solanum_already_built.stat.exists == False
|
||
|
- name: Create solanum user
|
||
|
ansible.builtin.user:
|
||
|
name: solanum
|
||
|
system: true
|
||
|
comment: Solanum service user
|
||
|
when: solanum_already_built.stat.exists == False
|
||
|
- name: Download solanum
|
||
|
ansible.builtin.git:
|
||
|
repo: 'https://github.com/solanum-ircd/solanum.git'
|
||
|
dest: /home/solanum/solanum
|
||
|
become: yes
|
||
|
become_user: solanum
|
||
|
when: solanum_already_built.stat.exists == False
|
||
|
- name: Decide whether we should run autogen.sh
|
||
|
ansible.builtin.stat:
|
||
|
path: /home/solanum/solanum/configure
|
||
|
register: configure_exists
|
||
|
when: solanum_already_built.stat.exists == False
|
||
|
- name: Run autogen.sh
|
||
|
ansible.builtin.command: ./autogen.sh
|
||
|
args:
|
||
|
chdir: /home/solanum/solanum
|
||
|
become: yes
|
||
|
become_user: solanum
|
||
|
when: solanum_already_built.stat.exists == False # or configure_exists.stat.exists == False
|
||
|
- name: See if Makefile exists
|
||
|
ansible.builtin.stat:
|
||
|
path: /home/solanum/solanum/Makefile
|
||
|
when: solanum_already_built.stat.exists == False
|
||
|
register: makefile_exists
|
||
|
- name: Run configure
|
||
|
ansible.builtin.command: ./configure --enable-oper-chghost --with-nicklen=50
|
||
|
args:
|
||
|
chdir: /home/solanum/solanum
|
||
|
become: yes
|
||
|
become_user: solanum
|
||
|
when: solanum_already_built.stat.exists == False # or makefile_exists.stat.exists == False
|
||
|
- name: Build solanum
|
||
|
ansible.builtin.make:
|
||
|
chdir: /home/solanum/solanum
|
||
|
become: yes
|
||
|
become_user: solanum
|
||
|
when: solanum_already_built.stat.exists == False
|
||
|
- name: Install solanum
|
||
|
ansible.builtin.make:
|
||
|
chdir: /home/solanum/solanum
|
||
|
target: install
|
||
|
become: yes
|
||
|
become_user: solanum
|
||
|
when: solanum_already_built.stat.exists == False
|
||
|
- name: See if there is currently a TLS certificate
|
||
|
ansible.builtin.stat:
|
||
|
path: /home/solanum/ircd/etc/cert.pem
|
||
|
register: tls_cert_exists
|
||
|
- name: Generate TLS certificate
|
||
|
ansible.builtin.command: 'openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /home/solanum/ircd/etc/key.pem -out /home/solanum/ircd/etc/cert.pem -subj "/C=US/O=AS4242422002/OU=IRC servers/CN={{ inventory_hostname }}"'
|
||
|
become: yes
|
||
|
become_user: solanum
|
||
|
when: tls_cert_exists.stat.exists == False
|
||
|
- name: Get certificate fingerprint
|
||
|
command: /home/solanum/ircd/bin/solanum-mkfingerprint spki_sha256 /home/solanum/ircd/etc/cert.pem
|
||
|
become: yes
|
||
|
become_user: solanum
|
||
|
register: tls_fingerprint
|
||
|
- name: Generate configuration file
|
||
|
ansible.builtin.template:
|
||
|
src: solanum/conf.j2
|
||
|
dest: /home/solanum/ircd/etc/ircd.conf
|
||
|
mode: '0600'
|
||
|
become: yes
|
||
|
become_user: solanum
|
||
|
- name: Generate motd
|
||
|
ansible.builtin.template:
|
||
|
src: solanum/motd.j2
|
||
|
dest: /home/solanum/ircd/etc/ircd.motd
|
||
|
mode: '0600'
|
||
|
become: yes
|
||
|
become_user: solanum
|
||
|
- name: Create systemd service
|
||
|
ansible.builtin.copy:
|
||
|
src: solanum/solanum.service
|
||
|
dest: /etc/systemd/system/solanum.service
|
||
|
mode: '0644'
|
||
|
when: ansible_service_mgr == 'systemd'
|
||
|
- name: Enable and start/reload solanum
|
||
|
ansible.builtin.systemd_service:
|
||
|
name: solanum.service
|
||
|
enabled: true
|
||
|
state: reloaded
|
||
|
daemon_reload: true
|
||
|
when: ansible_service_mgr == 'systemd'
|