Added role yourls

This commit is contained in:
Jim Martens 2021-04-24 12:03:51 +02:00
parent d398c22b56
commit 941b374f01
8 changed files with 85 additions and 0 deletions

View File

@ -0,0 +1,3 @@
---
yourls_repo: https://github.com/YOURLS/YOURLS
pseudonymize_repo: https://github.com/ubicoo/yourls-pseudonymize

View File

@ -0,0 +1,3 @@
---
dependencies:
- role: common

View File

@ -0,0 +1,37 @@
---
- name: copy configuration file
copy:
remote_src: yes
mode: preserve
src: ~/html/user/config-sample.php
dest: ~/html/user/config.php
- name: update database user
lineinfile:
path: ~/html/user/config.php
regexp: 'YOURLS_DB_USER'
line: define( 'YOURLS_DB_USER', '{{ uberspace_user }}' );
- name: update database password
lineinfile:
path: ~/html/user/config.php
regexp: 'YOURLS_DB_PASS'
line: define( 'YOURLS_DB_PASS', '{{ mysql_password }}' );
- name: update database name
lineinfile:
path: ~/html/user/config.php
regexp: 'YOURLS_DB_NAME'
line: define( 'YOURLS_DB_NAME', '{{ uberspace_user}}_yourls' );
- name: update domain
lineinfile:
path: ~/html/user/config.php
regexp: 'YOURLS_SITE'
line: define( 'YOURLS_SITE', 'https:/\/{{ domain }}' );
- name: set cookie key
lineinfile:
path: ~/html/user/config.php
regexp: 'YOURLS_COOKIEKEY'
line: define( 'YOURLS_COOKIEKEY', "{{ lookup('password', '/tmp/passwordfile chars=ascii_letters,digits,punctuation') }}" );
- name: set up user and password
lineinfile:
path: ~/html/user/config.php
regexp: "'username' => 'password'"
line: "'{{ yourls_user }}' => '{{ yourls_password }}'"

View File

@ -0,0 +1,9 @@
---
- name: install pymysql
pip:
name: pymysql
extra_args: --user
- name: create database
community.mysql.mysql_db:
name: '{{ uberspace_user }}_yourls'

View File

@ -0,0 +1,17 @@
---
- name: delete nocontent
file:
path: ~/html/nocontent.html
state: absent
- name: download YOURLS
git:
dest: ~/html/
repo: '{{ yourls_repo }}'
depth: 1
accept_hostkey: yes
- name: download pseudonymize plugin
git:
dest: ~/html/user/plugins/yourls-pseudonymize
repo: '{{ pseudonymize_repo }}'
depth: 1
accept_hostkey: yes

View File

@ -0,0 +1,4 @@
---
- include: download.yml
- include: database.yml
- include: configuration.yml

9
yourls.yml Normal file
View File

@ -0,0 +1,9 @@
---
- name: Set up YOURLS
hosts: uberspace
vars_files:
- general_vars.yml
- yourls_vars.yml
remote_user: "{{ uberspace_user }}"
roles:
- yourls

3
yourls_vars.yml.example Normal file
View File

@ -0,0 +1,3 @@
---
yourls_user: yourls
yourls_password: password