Added kafka and springBoot roles, minor cleanup, and use ansible-vault to hide sensitive data

This commit is contained in:
2023-08-17 20:14:04 +02:00
parent 2a81cb9073
commit dc07d21320
44 changed files with 378 additions and 40 deletions
@@ -0,0 +1,19 @@
---
- name: Create Spring Boot application directory
ansible.builtin.file:
state: directory
path: /opt/{{ spring_docker_path }}
owner: root
group: root
mode: "755"
- name: Copy docker compose file for application
ansible.builtin.template:
src: opt/application/docker-compose.yaml.j2
dest: /opt/{{ spring_docker_path }}/docker-compose.yaml
owner: root
group: root
mode: "644"
lstrip_blocks: true
- name: Start application docker container
community.docker.docker_compose:
project_src: /opt/{{ spring_docker_path }}
@@ -0,0 +1,6 @@
---
- name: Set up nginx for Spring Boot application
ansible.builtin.import_tasks: nginx.yaml
when: spring_use_nginx
- name: Set up docker-compose
ansible.builtin.import_tasks: docker.yaml
@@ -0,0 +1,38 @@
---
- name: Add HTTP site
ansible.builtin.template:
src: etc/nginx/sites-available/spring_domain.conf.j2
dest: /etc/nginx/sites-available/{{ spring_domain }}.conf
owner: root
group: root
mode: "644"
force: false
lstrip_blocks: true
- name: Disable default site
ansible.builtin.command:
cmd: rm /etc/nginx/sites-enabled/default
removes: /etc/nginx/sites-enabled/default
- name: Enable HTTP site
ansible.builtin.command:
cmd: ln -sf /etc/nginx/sites-available/{{ spring_domain }}.conf /etc/nginx/sites-enabled/{{ spring_domain }}.conf
creates: /etc/nginx/sites-enabled/{{ spring_domain }}.conf
notify: Reload nginx
- name: Check certificate existence
ansible.builtin.stat:
path: "/etc/letsencrypt/live/{{ spring_domain }}/cert.pem"
register: certificate
- name: Generate certificates
ansible.builtin.command:
cmd: >
certbot --nginx --non-interactive --keep-until-expiring
--no-eff-email
--email {{ admin_mail }}
--redirect
--renew-with-new-domains --agree-tos -d {{ spring_domain }}
creates: "/etc/letsencrypt/live/{{ spring_domain }}/cert.pem"
register: certbot_certificate_created
notify: Reload nginx
failed_when:
- "'Successfully received certificate.' not in certbot_certificate_created.stdout"
when:
- not certificate.stat.exists