๐Ÿ“— Ansible playbooks and roles for building an idempotent, interconnected and scalable infrastructure
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
ansible-playbooks/roles/shop/tasks/main.yml

93 lines
1.6 KiB

- name: install dependencies
include_tasks: tasks/install_packages.yml
vars:
package:
- nodejs
- npm
- name: create user and group
include_tasks: tasks/create_user.yml
vars:
user:
name: "{{ shop_user }}"
group: "{{ shop_group }}"
dir: "{{ shop_dir }}"
notify: restart shop
- name: recursively set owner and group for server dir
file:
path: "{{ shop_dir }}"
state: directory
recurse: yes
owner: "{{ shop_user }}"
group: "{{ shop_group }}"
- name: ensure server script has executable bit set
file:
path: "{{ shop_dir }}/app.mjs"
mode: "+x"
- name: template config file
template:
src: config.j2
dest: "{{ shop_dir }}/config.ini"
force: yes
lstrip_blocks: yes
notify: restart shop
- name: install npm dependencies
npm:
path: "{{ shop_dir }}"
no_optional: yes
ignore_scripts: yes
production: yes
become: yes
become_user: "{{ shop_user }}"
become_method: su
become_flags: '-s /bin/ash'
notify: restart shop
changed_when: no
- name: template init script
template:
src: init.j2
dest: /etc/init.d/shop
force: yes
mode: "+x"
notify: restart shop
- name: install and configure nginx
include_role:
name: nginx
vars:
nginx:
servers:
- conf: nginx_server
certs: "{{ host_tls }}"
- name: flush handlers
meta: flush_handlers
- name: add directories to backup plan
include_role:
name: backup
vars:
function: add
backup_items:
- "{{ shop_dir }}"
- name: enable and start shop
service:
name: shop
enabled: yes
state: started