Skip to content

Commit

Permalink
try to ping the workers
Browse files Browse the repository at this point in the history
  • Loading branch information
abikouo committed Dec 20, 2023
1 parent 9d11e47 commit 4e5b860
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
30 changes: 30 additions & 0 deletions roles/deploy_flask_app/tasks/setup_bastion.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
- 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: Install required packages
ansible.builtin.yum:
name: "{{ deploy_flask_app_bastion_host_required_packages }}"
state: present
become: true

- name: Generate ssh configuration for current user
ansible.builtin.user:
generate_ssh_key: true
state: present
name: "{{ deploy_flask_app_bastion_host_username }}"

- name: Copy remote ssh private key file into bastion
ansible.builtin.copy:
src: "{{ deploy_flask_app_bastion_ssh_private_key }}"
dest: "{{ deploy_flask_app_workers_ssh_private_key }}"
mode: 0400
21 changes: 21 additions & 0 deletions roles/deploy_flask_app/tasks/update_inventory.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
- name: Add bastion host into inventory
ansible.builtin.add_host:
hostname: bastion
ansible_ssh_user: "{{ deploy_flask_app_bastion_host_username }}"
ansible_host: "{{ deploy_flask_app__bastion_public_ip }}"
ansible_ssh_common_args: -o "UserKnownHostsFile=/dev/null" -o StrictHostKeyChecking=no -i {{ deploy_flask_app_bastion_ssh_private_key }}
ansible_python_interpreter: auto
ansible_host_name: "{{ deploy_flask_app__resource_prefix }}"
host_config:
public_subnet_id: "{{ deploy_flask_app__public_subnet_id }}"
private_subnet_id: "{{ deploy_flask_app__private_subnet_id }}"
image_id: "{{ deploy_flask_app__vm_image_id }}"
group_id: "{{ deploy_flask_app__group_id }}"
private_ip: "{{ deploy_flask_app__bastion_private_ip }}"
vpc_id: "{{ deploy_flask_app_vpc_id }}"
rds_info:
# host: "{{ deploy_flask_app__rds_host }}"
# name: "{{ deploy_flask_app__rds_dbname }}"
master_user_password: "{{ deploy_flask_app_rds_master_password }}"
master_username: "{{ deploy_flask_app_rds_master_username }}"
8 changes: 8 additions & 0 deletions roles/deploy_flask_app/templates/inventory.yml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
all:
hosts:
{{ item.instance_id }}:
ansible_host: "{{ item.private_ip_address }}"
workers_hosts: "{{ deploy_flask_app_workers_join }}"
ansible_ssh_user: "{{ deploy_flask_app_workers_user_name }}"
ansible_ssh_common_args: '-o "UserKnownHostsFile=/dev/null" -o StrictHostKeyChecking=no -i {{ deploy_flask_app_workers_ssh_private_key }}'
ansible_python_interpreter: auto

0 comments on commit 4e5b860

Please sign in to comment.