75 lines
2 KiB
YAML
75 lines
2 KiB
YAML
---
|
|
- name: deploy blog
|
|
hosts: blognas
|
|
remote_user: root
|
|
# environment:
|
|
# PATH: /root/.poetry/bin:{{ ansible_env.PATH }}
|
|
|
|
tasks:
|
|
- name: install system dependencies
|
|
pkgng:
|
|
name: git,python39,py39-sqlite3,jpeg-turbo,nginx,curl,vim
|
|
- name: make python3.9 default
|
|
file:
|
|
path: /usr/local/bin/python3
|
|
src: /usr/local/bin/python3.9
|
|
state: link
|
|
- name: install pip
|
|
shell:
|
|
cmd: python -m ensurepip
|
|
creates: /usr/local/lib/python3.9/site-packages/pip
|
|
- name: fetch code
|
|
git:
|
|
repo: https://git.sr.ht/~crocmagnon/blog
|
|
dest: /srv/blog
|
|
force: yes
|
|
- name: create venv
|
|
shell:
|
|
cmd: python -m venv /srv/blogvenv
|
|
creates: /srv/blogvenv/bin/python
|
|
- name: install poetry
|
|
shell:
|
|
cmd: . /srv/blogvenv/bin/activate && python -m pip install poetry==1.1.4
|
|
creates: /srv/blogvenv/bin/poetry
|
|
- name: install python dependencies
|
|
shell:
|
|
chdir: /srv/blog
|
|
cmd: . /srv/blogvenv/bin/activate && poetry install --no-dev
|
|
- name: install service
|
|
copy:
|
|
remote_src: yes
|
|
src: /srv/blog/ansible/blog.service
|
|
dest: /usr/local/etc/rc.d/blog
|
|
owner: root
|
|
group: wheel
|
|
mode: 0755
|
|
- name: enable and restart blog service
|
|
service:
|
|
name: blog
|
|
state: restarted
|
|
enabled: yes
|
|
- name: backup old nginx conf
|
|
copy:
|
|
remote_src: yes
|
|
src: /usr/local/etc/nginx/nginx.conf
|
|
dest: /usr/local/etc/nginx/nginx.conf.BKP
|
|
- name: install nginx conf
|
|
copy:
|
|
remote_src: yes
|
|
src: /srv/blog/ansible/nginx.conf
|
|
dest: /usr/local/etc/nginx/nginx.conf
|
|
owner: root
|
|
group: wheel
|
|
mode: 0644
|
|
notify:
|
|
- restart nginx
|
|
- name: enable nginx service
|
|
service:
|
|
name: nginx
|
|
state: started
|
|
enabled: yes
|
|
handlers:
|
|
- name: restart nginx
|
|
service:
|
|
name: nginx
|
|
state: restarted
|