mirror of
https://github.com/Crocmagnon/ansible.git
synced 2024-11-21 23:08:01 +01:00
add script to create new app easily
This commit is contained in:
parent
ed9fe33ccb
commit
3bcb33d76c
2 changed files with 52 additions and 0 deletions
8
new-app
Executable file
8
new-app
Executable file
|
@ -0,0 +1,8 @@
|
|||
#!/bin/bash
|
||||
|
||||
echo "creating directories for '$1'"
|
||||
mkdir -p "playbooks/apps/files/$1"
|
||||
mkdir -p "playbooks/apps/templates/$1"
|
||||
cp playbooks/apps/template.yaml.dist "playbooks/apps/$1.yaml"
|
||||
sed -i '' "s/==APP==/$1/g" "playbooks/apps/$1.yaml"
|
||||
echo "done"
|
44
playbooks/apps/template.yaml.dist
Normal file
44
playbooks/apps/template.yaml.dist
Normal file
|
@ -0,0 +1,44 @@
|
|||
---
|
||||
- name: ==APP==
|
||||
hosts: servers
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: Create dir
|
||||
ansible.builtin.file:
|
||||
path: "{{ dir }}"
|
||||
state: directory
|
||||
mode: "0775"
|
||||
- name: Write files
|
||||
ansible.builtin.copy:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ dir }}/"
|
||||
mode: preserve
|
||||
with_fileglob:
|
||||
- files/{{ app_name }}/*
|
||||
- files/{{ app_name }}/.*
|
||||
notify:
|
||||
- Restart service
|
||||
- name: Write templates
|
||||
ansible.builtin.template:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ dir }}/{{ item | basename | regex_replace('\\.j2$', '') }}"
|
||||
mode: preserve
|
||||
with_fileglob:
|
||||
- templates/{{ app_name }}/*.j2
|
||||
- templates/{{ app_name }}/.*.j2
|
||||
notify:
|
||||
- Restart service
|
||||
- name: Ensure service is started
|
||||
community.docker.docker_compose_v2:
|
||||
project_src: "{{ dir }}"
|
||||
state: present
|
||||
|
||||
handlers:
|
||||
- name: Restart service
|
||||
community.docker.docker_compose_v2:
|
||||
project_src: "{{ dir }}"
|
||||
state: restarted
|
||||
|
||||
vars:
|
||||
app_name: ==APP==
|
||||
dir: /mnt/data/{{ app_name }}
|
Loading…
Reference in a new issue