fix create service script for infra and add phoneassistant role
This commit is contained in:
parent
040994898b
commit
c0ab7feac5
@ -20,16 +20,16 @@ SERVICE_ORIGIN=$(prompt_with_default "Enter service origin URL" "git@git.simponi
|
||||
INTERNAL=$(prompt_with_default "Is the service internal? (yes/no)" "no")
|
||||
SERVICE_HOST=$(prompt_with_default "Enter service host" "ryo")
|
||||
PACKAGE_PATH=$(prompt_with_default "Enter package path" "$HOME/git/simponic/$SERVICE")
|
||||
HATECOMPUTERS_API_KEY=$(prompt_with_default "Enter hatecomputers API key (paste from clipboard)" "$(pbpaste)")
|
||||
HATECOMPUTERS_API_KEY=$(prompt_with_default "Enter hatecomputers API key (paste from clipboard)" "$(wl-paste)")
|
||||
|
||||
|
||||
function render_template() {
|
||||
cp -r template $PACKAGE_PATH
|
||||
ggrep -rlZ "{{ service }}" $PACKAGE_PATH | xargs -0 gsed -i "s/{{ service }}/$SERVICE/g"
|
||||
ggrep -rlZ "{{ service_host }}" $PACKAGE_PATH | xargs -0 gsed -i "s/{{ service_host }}/$SERVICE_HOST/g"
|
||||
ggrep -rlZ "{{ service_repo }}" $PACKAGE_PATH | xargs -0 gsed -i "s/{{ service_repo }}/$(echo $SERVICE_REPO | sed 's/\//\\\//g')/g"
|
||||
ggrep -rlZ "{{ service_port }}" $PACKAGE_PATH | xargs -0 gsed -i "s/{{ service_port }}/$SERVICE_PORT/g"
|
||||
ggrep -rlZ "{{ service_title }}" $PACKAGE_PATH | xargs -0 gsed -i "s/{{ service_title }}/$SERVICE_TITLE/g"
|
||||
grep -rlZ "{{ service }}" $PACKAGE_PATH | xargs -0 sed -i "s/{{ service }}/$SERVICE/g"
|
||||
grep -rlZ "{{ service_host }}" $PACKAGE_PATH | xargs -0 sed -i "s/{{ service_host }}/$SERVICE_HOST/g"
|
||||
grep -rlZ "{{ service_repo }}" $PACKAGE_PATH | xargs -0 sed -i "s/{{ service_repo }}/$(echo $SERVICE_REPO | sed 's/\//\\\//g')/g"
|
||||
grep -rlZ "{{ service_port }}" $PACKAGE_PATH | xargs -0 sed -i "s/{{ service_port }}/$SERVICE_PORT/g"
|
||||
grep -rlZ "{{ service_title }}" $PACKAGE_PATH | xargs -0 sed -i "s/{{ service_title }}/$SERVICE_TITLE/g"
|
||||
}
|
||||
|
||||
function test_and_commit_code() {
|
||||
@ -60,12 +60,12 @@ function add_dns_records() {
|
||||
name="$SERVICE.internal.simponic.xyz."
|
||||
content="$SERVICE_HOST.internal.simponic.xyz."
|
||||
curl -H "Authorization: Bearer $HATECOMPUTERS_API_KEY" \
|
||||
-F "type=CNAME&name=$name&content=$content.internal.simponic.xyz.&ttl=43200&internal=on" \
|
||||
-F "type=CNAME&name=$name&content=$content&ttl=43200&internal=on" \
|
||||
$DNS_ENDPOINT
|
||||
else
|
||||
name="$SERVICE.simponic.xyz."
|
||||
content="$SERVICE_HOST.simponic.xyz."
|
||||
gsed -i "s|;; CNAME Records|;; CNAME Records\n$name\t43200\tIN\tCNAME\t$content|" $BIND_FILE
|
||||
sed -i "s|;; CNAME Records|;; CNAME Records\n$name\t43200\tIN\tCNAME\t$content|" $BIND_FILE
|
||||
fi
|
||||
}
|
||||
|
||||
@ -149,6 +149,14 @@ function create_role() {
|
||||
group: root
|
||||
mode: 0777
|
||||
|
||||
- name: ensure $SERVICE env exist
|
||||
file:
|
||||
path: /etc/docker/compose/$SERVICE/.env
|
||||
state: file
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0700
|
||||
|
||||
- name: build $SERVICE docker-compose.yml.j2
|
||||
template:
|
||||
src: ../templates/docker-compose.yml.j2
|
||||
|
4
deploy-phoneassistant.yml
Normal file
4
deploy-phoneassistant.yml
Normal file
@ -0,0 +1,4 @@
|
||||
- name: deploy phoneassistant
|
||||
hosts: phoneassistant
|
||||
roles:
|
||||
- phoneassistant
|
@ -93,4 +93,6 @@ ryo ansible_user=root ansible_connection=ssh
|
||||
[something]
|
||||
ryo ansible_user=root ansible_connection=ssh
|
||||
[whois]
|
||||
ryo ansible_user=root ansible_connection=ssh
|
||||
ryo ansible_user=root ansible_connection=ssh
|
||||
[phoneassistant]
|
||||
johan ansible_user=root ansible_connection=ssh
|
30
roles/phoneassistant/tasks/main.yml
Normal file
30
roles/phoneassistant/tasks/main.yml
Normal file
@ -0,0 +1,30 @@
|
||||
---
|
||||
- name: ensure phoneassistant docker/compose exist
|
||||
file:
|
||||
path: /etc/docker/compose/phoneassistant
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0700
|
||||
|
||||
- name: ensure phoneassistant db exist
|
||||
file:
|
||||
path: /etc/docker/compose/phoneassistant/db
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0777
|
||||
|
||||
- name: build phoneassistant docker-compose.yml.j2
|
||||
template:
|
||||
src: ../templates/docker-compose.yml.j2
|
||||
dest: /etc/docker/compose/phoneassistant/docker-compose.yml
|
||||
owner: root
|
||||
group: root
|
||||
mode: u=rw,g=r,o=r
|
||||
|
||||
- name: daemon-reload and enable phoneassistant
|
||||
ansible.builtin.systemd_service:
|
||||
state: restarted
|
||||
enabled: true
|
||||
name: docker-compose@phoneassistant
|
16
roles/phoneassistant/templates/docker-compose.yml.j2
Normal file
16
roles/phoneassistant/templates/docker-compose.yml.j2
Normal file
@ -0,0 +1,16 @@
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
api:
|
||||
restart: always
|
||||
image: git.simponic.xyz/simponic/phoneassistant
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "--spider", "http://localhost:8080/api/health"]
|
||||
interval: 5s
|
||||
timeout: 10s
|
||||
retries: 5
|
||||
env_file: .env
|
||||
volumes:
|
||||
- ./db:/app/db
|
||||
ports:
|
||||
- "127.0.0.1:9082:8080"
|
Loading…
x
Reference in New Issue
Block a user