forked from opencrvs/opencrvs-countryconfig
-
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
8 changed files
with
176 additions
and
21 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
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
# | ||
# OpenCRVS is also distributed under the terms of the Civil Registration | ||
# & Healthcare Disclaimer located at http://opencrvs.org/license. | ||
# | ||
# Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. | ||
|
||
all: | ||
vars: | ||
users: [] | ||
|
||
jump: | ||
hosts: | ||
opencrvs-bastion: | ||
ansible_host: '159.89.14.13' |
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
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 |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
# | ||
# OpenCRVS is also distributed under the terms of the Civil Registration | ||
# & Healthcare Disclaimer located at http://opencrvs.org/license. | ||
# | ||
# Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. | ||
--- | ||
- hosts: docker-manager-first | ||
become: yes | ||
tasks: | ||
- name: Fetch the public SSH key so it can be transferred to the jump machine | ||
fetch: | ||
src: '{{ provisioning_user }}/.ssh/authorized_keys' | ||
dest: '/tmp/docker-manager-first_id_rsa.pub' | ||
flat: yes | ||
tags: | ||
- jump | ||
|
||
- hosts: jump | ||
become: yes | ||
become_method: sudo | ||
tasks: | ||
- name: Ensure jump user is present | ||
user: | ||
name: 'jump' | ||
state: present | ||
create_home: true | ||
home: '/home/jump' | ||
shell: /bin/bash | ||
tags: | ||
- jump | ||
|
||
- name: Ensure application servers can login to jump server | ||
blockinfile: | ||
path: '/home/jump/.ssh/authorized_keys' | ||
block: | | ||
{{ lookup('file', '/tmp/docker-manager-first_id_rsa.pub') }} | ||
marker: '# {mark} ANSIBLE MANAGED BLOCK docker-manager-first {{ manager_hostname }}' | ||
create: yes | ||
mode: 0600 | ||
owner: 'jump' | ||
|
||
tags: | ||
- jump | ||
|
||
- name: Only require public key from the user jump | ||
blockinfile: | ||
path: /etc/ssh/sshd_config | ||
block: | | ||
Match User jump | ||
PasswordAuthentication no | ||
AuthenticationMethods publickey | ||
marker: '# {mark} ANSIBLE MANAGED BLOCK FOR USER jump' | ||
become: yes | ||
|
||
- hosts: docker-manager-first | ||
become: yes | ||
tasks: | ||
- name: Set destination server | ||
set_fact: | ||
destination_server: "{{ hostvars[groups['jump'][0]].ansible_host }}" | ||
tags: | ||
- jump | ||
|
||
- name: Check SSH connection to destination server | ||
shell: ssh -o BatchMode=yes -o StrictHostKeyChecking=no -o ConnectTimeout=5 jump@{{ destination_server }} 'echo Connection successful' | ||
remote_user: '{{ provisioning_user }}' | ||
register: ssh_test | ||
ignore_errors: yes | ||
tags: | ||
- jump | ||
|
||
- name: Fail if SSH connection test failed | ||
fail: | ||
msg: 'SSH connection to the jump server failed' | ||
when: ssh_test.rc != 0 | ||
tags: | ||
- jump |
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