Add plume role
This commit is contained in:
parent
fcfdcce0c0
commit
7cb1725c93
13
roles/plume/files/plume.service
Normal file
13
roles/plume/files/plume.service
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
[Unit]
|
||||||
|
Description=plume
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
User=plume
|
||||||
|
WorkingDirectory=/var/www/plume/www
|
||||||
|
ExecStart=/var/www/plume/.cargo/bin/plume
|
||||||
|
TimeoutSec=30
|
||||||
|
Restart=always
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
168
roles/plume/tasks/main.yml
Normal file
168
roles/plume/tasks/main.yml
Normal file
|
@ -0,0 +1,168 @@
|
||||||
|
---
|
||||||
|
- name: Update repositories cache and install package
|
||||||
|
apt:
|
||||||
|
name: "{{ packages }}"
|
||||||
|
state: latest
|
||||||
|
update_cache: yes
|
||||||
|
vars:
|
||||||
|
packages:
|
||||||
|
- libpq-dev
|
||||||
|
- gettext
|
||||||
|
- git
|
||||||
|
- curl
|
||||||
|
- gcc
|
||||||
|
- make
|
||||||
|
- openssl
|
||||||
|
- libssl-dev
|
||||||
|
- pkg-config
|
||||||
|
- pwgen
|
||||||
|
|
||||||
|
- name: check if Plume folder exists
|
||||||
|
stat:
|
||||||
|
path: /var/www/plume/www/.git/config
|
||||||
|
register: plumefolder
|
||||||
|
|
||||||
|
- name: Create /var/www folder
|
||||||
|
file:
|
||||||
|
path: /var/www
|
||||||
|
state: directory
|
||||||
|
mode: 0755
|
||||||
|
|
||||||
|
|
||||||
|
- name: Add the user 'Plume'
|
||||||
|
user:
|
||||||
|
name: plume
|
||||||
|
shell: /bin/bash
|
||||||
|
home: /var/www/plume
|
||||||
|
create_home: yes
|
||||||
|
when: plumefolder.stat.exists == False
|
||||||
|
|
||||||
|
- name: install rust by rustup
|
||||||
|
shell: curl https://sh.rustup.rs -sSf | sh -s -- -y
|
||||||
|
become: yes
|
||||||
|
become_user: plume
|
||||||
|
when: plumefolder.stat.exists == False
|
||||||
|
|
||||||
|
- name: Update rustup
|
||||||
|
shell: /var/www/plume/.cargo/bin/rustup update
|
||||||
|
become: yes
|
||||||
|
become_user: plume
|
||||||
|
when: plumefolder.stat.exists == True
|
||||||
|
|
||||||
|
- name: install rust by rustup
|
||||||
|
shell: export PATH="$PATH:/var/www/plume/.cargo/bin:/var/www/plume/.local/bin:/usr/local/sbin"
|
||||||
|
become: yes
|
||||||
|
become_user: plume
|
||||||
|
when: plumefolder.stat.exists == False
|
||||||
|
|
||||||
|
- name: Clone plume repo
|
||||||
|
git:
|
||||||
|
repo: https://github.com/Plume-org/Plume.git
|
||||||
|
dest: /var/www/plume/www
|
||||||
|
force: yes
|
||||||
|
become: yes
|
||||||
|
become_user: plume
|
||||||
|
|
||||||
|
- name: install diesel
|
||||||
|
shell: "cd /var/www/plume/www && /var/www/plume/.cargo/bin/cargo install -j 1 diesel_cli --no-default-features --features postgres --version '=1.3.0' --force"
|
||||||
|
become: yes
|
||||||
|
become_user: plume
|
||||||
|
|
||||||
|
- name: build front-end
|
||||||
|
shell: "cd /var/www/plume/www && /var/www/plume/.cargo/bin/cargo install -j 1 cargo-web --force"
|
||||||
|
become: yes
|
||||||
|
become_user: plume
|
||||||
|
|
||||||
|
- name: Build front-end
|
||||||
|
shell: "cd /var/www/plume/www && /var/www/plume/.cargo/bin/cargo web deploy -p plume-front"
|
||||||
|
become: yes
|
||||||
|
become_user: plume
|
||||||
|
|
||||||
|
- name: Build the back-end
|
||||||
|
shell: "cd /var/www/plume/www && /var/www/plume/.cargo/bin/cargo install -j 1 --no-default-features --features postgres --force"
|
||||||
|
become: yes
|
||||||
|
become_user: plume
|
||||||
|
|
||||||
|
- name: Build plm, the CLI helper
|
||||||
|
shell: "cd /var/www/plume/www && /var/www/plume/.cargo/bin/cargo install -j 1 --no-default-features --features postgres --path plume-cli --force"
|
||||||
|
become: yes
|
||||||
|
become_user: plume
|
||||||
|
|
||||||
|
#- debug:
|
||||||
|
# msg: "{{ plume }}"
|
||||||
|
|
||||||
|
- name: Add ssh ignore host
|
||||||
|
template:
|
||||||
|
src: env.j2
|
||||||
|
dest: /var/www/plume/www/.env
|
||||||
|
mode: 0644
|
||||||
|
owner: plume
|
||||||
|
group: plume
|
||||||
|
|
||||||
|
- name: "Diesel run"
|
||||||
|
shell: "/var/www/plume/.cargo/bin/diesel migration run"
|
||||||
|
args:
|
||||||
|
chdir: /var/www/plume/www
|
||||||
|
become: yes
|
||||||
|
become_user: plume
|
||||||
|
|
||||||
|
- name: "Initialise Plume"
|
||||||
|
shell: "/var/www/plume/.cargo/bin/plm instance new --name {{ plume.name }} --domain {{ plume.domain }} --default-license {{ plume.licence }}"
|
||||||
|
args:
|
||||||
|
chdir: /var/www/plume/www
|
||||||
|
become: yes
|
||||||
|
become_user: plume
|
||||||
|
when: plumefolder.stat.exists == False
|
||||||
|
|
||||||
|
- name: Generate password
|
||||||
|
shell: "pwgen 21 1"
|
||||||
|
become: yes
|
||||||
|
become_user: plume
|
||||||
|
register: password
|
||||||
|
when: plumefolder.stat.exists == False
|
||||||
|
|
||||||
|
- name: Display Password
|
||||||
|
debug: msg={{ password.stdout }}
|
||||||
|
when: plumefolder.stat.exists == False
|
||||||
|
|
||||||
|
- name: Initialise Plume
|
||||||
|
shell: "/var/www/plume/.cargo/bin/plm users new --admin --display-name {{ plume.display_name }} --name {{ plume.admin_name }} --password {{ password.stdout }} --email {{ plume.admin_email }}"
|
||||||
|
args:
|
||||||
|
chdir: /var/www/plume/www
|
||||||
|
become: yes
|
||||||
|
become_user: plume
|
||||||
|
when: plumefolder.stat.exists == False
|
||||||
|
|
||||||
|
- name: Initialise Plume
|
||||||
|
shell: "cd /var/www/plume/www && /var/www/plume/.cargo/bin/plm search init"
|
||||||
|
become: yes
|
||||||
|
become_user: plume
|
||||||
|
when: plumefolder.stat.exists == False
|
||||||
|
|
||||||
|
- name: Copy plume service
|
||||||
|
copy:
|
||||||
|
src: plume.service
|
||||||
|
dest: /etc/systemd/system/plume.service
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0640
|
||||||
|
|
||||||
|
- name: Reload systemd
|
||||||
|
shell: "systemctl daemon-reload"
|
||||||
|
|
||||||
|
- name: Start service plume
|
||||||
|
service:
|
||||||
|
name: plume.service
|
||||||
|
state: started
|
||||||
|
when: plumefolder.stat.exists == False
|
||||||
|
|
||||||
|
- name: Restart service plume
|
||||||
|
service:
|
||||||
|
name: plume.service
|
||||||
|
state: restarted
|
||||||
|
when: plumefolder.stat.exists == True
|
||||||
|
|
||||||
|
- name: Enable service plume
|
||||||
|
service:
|
||||||
|
name: plume.service
|
||||||
|
enabled: yes
|
24
roles/plume/templates/env.j2
Normal file
24
roles/plume/templates/env.j2
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
# The address of the database
|
||||||
|
# (replace USER, PASSWORD, PORT and DATABASE_NAME with your values)
|
||||||
|
#
|
||||||
|
# If you are using SQlite, use the path of the database file (`plume.db` for instance)
|
||||||
|
DATABASE_URL=postgres://{{ plume.db_user }}:{{ plume.db_password }}@{{ plume.db_host }}:{{ plume.db_port }}/{{ plume.db_name }}
|
||||||
|
|
||||||
|
# For PostgreSQL: migrations/postgres
|
||||||
|
# For SQlite: migrations/sqlite
|
||||||
|
MIGRATION_DIRECTORY=migrations/postgres
|
||||||
|
|
||||||
|
# The domain on which your instance will be available
|
||||||
|
BASE_URL={{ plume.domain }}
|
||||||
|
# Secret key used for private cookies and CSRF protection
|
||||||
|
# You can generate one with `openssl rand -base64 32`
|
||||||
|
ROCKET_SECRET_KEY={{ plume.rocket_secret_key }}
|
||||||
|
ROCKET_ADDRESS={{ plume.rocket_address }}
|
||||||
|
ROCKET_PORT={{ plume.rocket_port }}
|
||||||
|
|
||||||
|
# Mail settings
|
||||||
|
MAIL_SERVER={{ plume.mail_server }}
|
||||||
|
MAIL_USER={{ plume.mail_user }}
|
||||||
|
MAIL_PASSWORD={{ plume.mail_password }}
|
||||||
|
MAIL_HELO_NAME={{ plume.mail_helo_name }}
|
||||||
|
|
21
vars.yml
Normal file
21
vars.yml
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
---
|
||||||
|
plume:
|
||||||
|
name: "Plume"
|
||||||
|
domain: "plume.me"
|
||||||
|
licence: "CC-BY-CA"
|
||||||
|
display_name: "Admin"
|
||||||
|
admin_name: "admin"
|
||||||
|
admin_email: "admin@domain.tld"
|
||||||
|
rocket_address: "0.0.0.0"
|
||||||
|
rocket_port: "7878"
|
||||||
|
rocket_secret_key: "ouhyufhdguoyfdsgufygsdufygsdufygsdf="
|
||||||
|
base_url: plume.me
|
||||||
|
db_host: 127.0.0.1
|
||||||
|
db_user: plume
|
||||||
|
db_password: dsdfsdfsdfsdfsdfsf
|
||||||
|
db_port: 5432
|
||||||
|
db_name: plume
|
||||||
|
mail_server: smtp.domain.tld
|
||||||
|
mail_user: noreply@plum.me
|
||||||
|
mail_password: 'Hfdsfsdfsdfsd'
|
||||||
|
mail_helo_name: plu.me
|
Reference in a new issue