Skip to content
This repository has been archived by the owner on Nov 22, 2024. It is now read-only.

Commit

Permalink
Merge branch 'master' of github.com:pariyatti/kosa
Browse files Browse the repository at this point in the history
  • Loading branch information
deobald committed Jul 20, 2024
2 parents 15f7993 + b6e2ef9 commit 39edfd8
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 8 deletions.
49 changes: 49 additions & 0 deletions ops/ansible/reseed_looped_txt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
- hosts: app
remote_user: "{{ user_acc }}"
vars_files:
- vars.yml

tasks:
- name: stop kosa
systemd: name={{ app_name }} state=stopped
become: yes

- name: clone txt files from private repo
tags: code
environment:
GIT_SSH_COMMAND: "ssh -i {{ DEPLOY_KEY_PATH }}"
make:
chdir: "{{ app_dir }}"
target: "{{ seed_txt_clone_target }}"
become: yes
become_user: "{{ user_acc }}"

- name: truncate (3x looped txt card types) xtdb database
tags: code
make:
chdir: "{{ app_dir }}"
target: "{{ seed_txt_trunc_target }}"
become: yes
become_user: "{{ user_acc }}"

- name: update (3x looped txt card types) xtdb database
tags: code
make:
chdir: "{{ app_dir }}"
target: "{{ update_txt_apply_target }}"
become: yes
become_user: "{{ user_acc }}"

- name: Recursively change ownership of srv directory
ansible.builtin.file:
path: "{{ srv_dir }}"
state: directory
recurse: yes
owner: "{{ user_acc }}"
group: "{{ user_acc }}"
become: yes

- name: start kosa
systemd: name={{ app_name }} state=started enabled=yes
become: yes
15 changes: 14 additions & 1 deletion ops/terraform/modules/kosa_server_lightsail/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,25 @@ resource "null_resource" "ansible_seed_data" {
}
}

# reseed_txt_files
resource "null_resource" "ansible_reseed_txt_files" {
depends_on = [
null_resource.ansible_config,
null_resource.ansible_deploy
]
count = var.reseed_txt_files && !var.update_txt_files ? 1 : 0

provisioner "local-exec" {
command = "cd ../../ansible && ansible-playbook --extra-vars @secrets.yml --vault-password-file ~/.kosa/ansible-password --limit ${var.server_name}.pariyatti.app -i hosts reseed_looped_txt.yml"
}
}

resource "null_resource" "ansible_update_data" {
depends_on = [
null_resource.ansible_config,
null_resource.ansible_deploy
]
count = var.update_txt_files
count = var.update_txt_files && !var.reseed_txt_files ? 1:0

provisioner "local-exec" {
command = "cd ../../ansible && ansible-playbook --extra-vars @secrets.yml --vault-password-file ~/.kosa/ansible-password --limit ${var.server_name}.pariyatti.app -i hosts update_looped_txt.yml"
Expand Down
12 changes: 9 additions & 3 deletions ops/terraform/modules/kosa_server_lightsail/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ variable "user_data" {
}

variable "update_txt_files" {
type = number
default = 0
description = "Manually set to 1 to update the txt files"
type = bool
default = false
description = "Manually set to 1 to update the txt files. At a time either this or reseed_txt_files should be set to 1"
}

variable "reseed_txt_files" {
type = bool
default = false
description = "Manually set to 1 to reseed the txt files. At a time either this or update_txt_files should be set to 1"
}
6 changes: 4 additions & 2 deletions ops/terraform/production/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ module "kosa-production" {

server_blueprint_id = "ubuntu_22_04"

# Manually set to 1 to update the txt files
update_txt_files = 0
# Manually set to true to update the txt files
update_txt_files = false
# Manually set to true to reseed the txt files
reseed_txt_files = false
server_tags = {
env = "production"
}
Expand Down
6 changes: 4 additions & 2 deletions ops/terraform/sandbox/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ module "kosa-sandbox" {

server_blueprint_id = "ubuntu_22_04"

# Manually set to 1 to update the txt files
update_txt_files = 0
# Manually set to true to update the txt files
update_txt_files = false
# Manually set to true to reseed the txt files
reseed_txt_files = false
server_tags = {
env = "sandbox"
}
Expand Down

0 comments on commit 39edfd8

Please sign in to comment.