generated from ansible-collections/collection_template
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
112 additions
and
305 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
--- | ||
deploy_flask_app_workers_ssh_private_key: "/tmp/id_rsa" | ||
deploy_flask_app_workers_ssh_private_key: /tmp/id_rsa | ||
deploy_flask_app_container_image: docker.io/aubinredhat/webapp:1.0.0 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,54 @@ | ||
--- | ||
- name: Generate configuration (inventory, vars) from templates | ||
ansible.builtin.template: | ||
src: "{{ item.src }}" | ||
dest: "{{ item.dest }}" | ||
mode: 0644 | ||
with_items: | ||
- src: inventory.j2 | ||
dest: ~/inventory.ini | ||
- src: vars.yaml.j2 | ||
dest: vars.yaml | ||
- name: Deploy application into worker | ||
delegate_to: "{{ worker_id }}" | ||
vars: | ||
deploy_flask_app__worker_container_name: "webapp-container1" | ||
block: | ||
- name: Update ssh_config | ||
ansible.builtin.lineinfile: | ||
path: /etc/ssh/sshd_config | ||
regex: "{{ item.regex }}" | ||
line: "{{ item.line }}" | ||
loop: | ||
- regex: ^(# *)?ClientAliveInterval | ||
line: ClientAliveInterval 1200 | ||
- regex: ^(# *)?ClientAliveCountMax | ||
line: ClientAliveCountMax 3 | ||
become: true | ||
|
||
- name: Ensure workers are reachable from bastion host | ||
ansible.builtin.command: | ||
cmd: "ansible -m ping -i ~/inventory.ini all" | ||
- name: Install Podman | ||
ansible.builtin.yum: | ||
name: | ||
- podman | ||
update_cache: False | ||
state: present | ||
become: true | ||
|
||
- name: Initialize database tables | ||
ansible.builtin.shell: | ||
cmd: > | ||
podman run --rm | ||
-e FLASK_APP="{{ deploy_flask_app_config.app_dir }}" | ||
-e FLASK_ENV="{{ deploy_flask_app_config.env }}" | ||
-e DATABASE_HOST="{{ deploy_flask_app_setup.add_host.host_vars.host_config.rds_info.host }}" | ||
-e DATABASE_INSTANCE="{{ deploy_flask_app_setup.add_host.host_vars.host_config.rds_info.name }}" | ||
-e DATABASE_USER="{{ deploy_flask_app_setup.add_host.host_vars.host_config.rds_info.master_username }}" | ||
-e DATABASE_PASSWORD="{{ deploy_flask_app_setup.add_host.host_vars.host_config.rds_info.master_user_password }}" | ||
-e ADMIN_USER="{{ deploy_flask_app_config.admin_user }}" | ||
-e ADMIN_PASSWORD="{{ deploy_flask_app_config.admin_password }}" | ||
-e WORKER_HOSTNAME="{{ inventory_hostname }}" | ||
-e WORKERS_HOSTS="bastion" | ||
webapp flask {{ deploy_flask_app_force_init | bool | ternary('force-init-db', 'init-db') }} | ||
run_once: true | ||
changed_when: false | ||
- name: Check running container | ||
ansible.builtin.shell: | ||
cmd: > | ||
podman container ps -a | ||
-f name={{ deploy_flask_app__worker_container_name }} | ||
--format=.Names | ||
register: container | ||
changed_when: false | ||
|
||
- name: Copy playbook into bastion host | ||
ansible.builtin.copy: | ||
src: run_app.yaml | ||
dest: ~/playbook.yaml | ||
mode: 0644 | ||
|
||
- name: Deploy application into workers | ||
ansible.builtin.shell: | ||
cmd: > | ||
ansible-playbook playbook.yaml -i inventory.ini -vvv | ||
-e '@vars.yaml' | ||
-e registry_host_port='{{ deploy_flask_app_setup.add_host.host_vars.host_config.private_ip }}:{{ deploy_flask_app_listening_port }}' | ||
args: | ||
chdir: ~/ | ||
changed_when: false | ||
|
||
- name: Debug application url | ||
ansible.builtin.debug: | ||
msg: "Application url: {{ deploy_flask_app_lb_result.elb.dns_name }}:{{ deploy_flask_app_listening_port }}" | ||
- name: Run application instance | ||
ansible.builtin.shell: | ||
cmd: >- | ||
Check warning on line 38 in roles/deploy_flask_app/tasks/deploy_app.yaml GitHub Actions / ansible-lintjinja[spacing]
|
||
podman run --rm | ||
-e FLASK_APP="{{ deploy_flask_app_config.app_dir }}" | ||
-e FLASK_ENV="{{ deploy_flask_app_config.env }}" | ||
-e DATABASE_HOST="{{ deploy_flask_app__rds_host }}" | ||
-e DATABASE_INSTANCE="{{ deploy_flask_app__rds_dbname }}" | ||
-e DATABASE_USER="{{ deploy_flask_app_rds_master_username }}" | ||
-e DATABASE_PASSWORD="{{deploy_flask_app_rds_master_password }}" | ||
-e ADMIN_USER="{{ deploy_flask_app_config.admin_user }}" | ||
-e ADMIN_PASSWORD="{{ deploy_flask_app_config.admin_password }}" | ||
-e WORKER_HOSTNAME="{{ worker_id }}" | ||
-e WORKERS_HOSTS="{{ deploy_flask_app_instances | join(',') }}" | ||
-p 5000:5000 --name {{ deploy_flask_app__worker_container_name }} | ||
-d {{ deploy_flask_app_container_image }} | ||
when: | ||
- container.stdout == "" | ||
changed_when: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.