-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mepts 184 setup internal server for partners databases #4
base: master
Are you sure you want to change the base?
Changes from all commits
715c96e
14f8a02
1760de1
6fc4384
05c2585
b985726
618d733
e4e5eeb
3f82180
9bb5c49
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
data/ | ||
*.retry | ||
**/.vagrant | ||
node_modules/ | ||
node_modules/ | ||
|
||
../.vscode/ | ||
.vscode/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
- hosts: my_hosts | ||
vars: | ||
allowed_ports: | ||
- 80 | ||
- 22 | ||
- 8080 | ||
denied_ports: | ||
- | ||
docker_network: "internal_server" | ||
mysql_root_password: !vault | | ||
$ANSIBLE_VAULT;1.1;AES256 | ||
33326462323566343335316438626431353437373163613963333630366539313362393135653134 | ||
3034616636646666303537663932326164313539336533350a613163633363353731616161633363 | ||
34613763613462623165666532326133646332313330373733386433313765306232366233313132 | ||
3163633837333630380a353562623732613463313037316130636638633635626461393530346136 | ||
6162 | ||
mysql_openmrs_password: !vault | | ||
$ANSIBLE_VAULT;1.1;AES256 | ||
37623764643735393733613737623266633863353438623035653665646134646463623638346638 | ||
3339383030623632663365383334323830363631636661370a393036306366323963366434323039 | ||
34633262386266636461386535336137383332623766643932373036343061616563633033643862 | ||
3335643536613861340a643934633133353566396230336331646234376164306638633865373162 | ||
3264 | ||
|
||
become: yes | ||
roles: | ||
- basic | ||
- docker | ||
- mysql | ||
- openmrs | ||
|
||
... |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
Role Name | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it needed to create a new 'basic' role, instead of modifying the existing 'common' role? |
||
========= | ||
|
||
A brief description of the role goes here. | ||
|
||
Requirements | ||
------------ | ||
|
||
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. | ||
|
||
Role Variables | ||
-------------- | ||
|
||
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. | ||
|
||
Dependencies | ||
------------ | ||
|
||
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. | ||
|
||
Example Playbook | ||
---------------- | ||
|
||
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: | ||
|
||
- hosts: servers | ||
roles: | ||
- { role: username.rolename, x: 42 } | ||
|
||
License | ||
------- | ||
|
||
BSD | ||
|
||
Author Information | ||
------------------ | ||
|
||
An optional section for the role authors to include contact information, or a website (HTML is not allowed). |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
# defaults file for ../basic/ | ||
public_network_interface: eth0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
# handlers file for ../basic/ | ||
|
||
- include: restart_sshd.yml | ||
- include: reload_ufw.yml |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
- name: reload ufw | ||
ufw: | ||
state: reloaded |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
- name: restart sshd | ||
service: | ||
name: sshd | ||
state: restarted |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
galaxy_info: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not familiar with galaxy_info - what is it meant for? |
||
author: your name | ||
description: your description | ||
company: your company (optional) | ||
|
||
# If the issue tracker for your role is not on github, uncomment the | ||
# next line and provide a value | ||
# issue_tracker_url: http://example.com/issue/tracker | ||
|
||
# Choose a valid license ID from https://spdx.org - some suggested licenses: | ||
# - BSD-3-Clause (default) | ||
# - MIT | ||
# - GPL-2.0-or-later | ||
# - GPL-3.0-only | ||
# - Apache-2.0 | ||
# - CC-BY-4.0 | ||
license: license (GPL-2.0-or-later, MIT, etc) | ||
|
||
min_ansible_version: 2.4 | ||
|
||
# If this a Container Enabled role, provide the minimum Ansible Container version. | ||
# min_ansible_container_version: | ||
|
||
# | ||
# Provide a list of supported platforms, and for each platform a list of versions. | ||
# If you don't wish to enumerate all versions for a particular platform, use 'all'. | ||
# To view available platforms and versions (or releases), visit: | ||
# https://galaxy.ansible.com/api/v1/platforms/ | ||
# | ||
# platforms: | ||
# - name: Fedora | ||
# versions: | ||
# - all | ||
# - 25 | ||
# - name: SomePlatform | ||
# versions: | ||
# - all | ||
# - 1.0 | ||
# - 7 | ||
# - 99.99 | ||
|
||
galaxy_tags: [] | ||
# List tags for your role here, one per line. A tag is a keyword that describes | ||
# and categorizes the role. Users find roles by searching for tags. Be sure to | ||
# remove the '[]' above, if you add tags to this list. | ||
# | ||
# NOTE: A tag is limited to a single word comprised of alphanumeric characters. | ||
# Maximum 20 tags per role. | ||
|
||
dependencies: [] | ||
# List your role dependencies here, one per line. Be sure to remove the '[]' above, | ||
# if you add dependencies to this list. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
digraph G { | ||
label="MOASIS QA Server with all partner dbs"; | ||
rankdir="LR"; | ||
|
||
start_here [label="it's me(start here)"]; | ||
nginx [label="Nginx Container"]; | ||
|
||
FGH [label="Tomcat - FGH"]; | ||
FHI360 [label="Tomcat - FHI360"]; | ||
ARIEL [label="Tomcat - ARIEL"]; | ||
EGPAF [label="Tomcat - EGPAF"]; | ||
ICAP [label="Tomcat - ICAP"]; | ||
CCS [label="Tomcat - CCS"]; | ||
|
||
subgraph cluster_0 { | ||
label="MySQL Container"; | ||
style=filled; | ||
|
||
FGH_DB [label="Db: openmrsFGH"]; | ||
ARIEL_DB [label="Db: openmrsARIEL"]; | ||
ICAP_DB [label="Db: openmrsICAP"]; | ||
FHI360_DB [label="Db: openmrsFHI360"]; | ||
EGPAF_DB [label="Db: openmrsEGPAF"]; | ||
CCS_DB [label="Db: openmrsCCS"]; | ||
} | ||
|
||
start_here -> nginx; | ||
nginx -> FGH -> FGH_DB; | ||
nginx -> ARIEL -> ARIEL_DB; | ||
nginx -> EGPAF -> EGPAF_DB; | ||
nginx -> ICAP -> ICAP_DB; | ||
nginx -> FHI360 -> FHI360_DB; | ||
nginx -> CCS -> CCS_DB; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
|
||
|
||
- include: debian_based/allow_ufw_ports.yml | ||
- include: debian_based/deploy_sshd_config.yml | ||
- include: debian_based/enable_ufw.yml | ||
- include: debian_based/update-ufw-rules.yml | ||
|
||
- name: installing vim for debian based OS | ||
apt: | ||
name: vim | ||
state: present | ||
|
||
- name: installing git for debian based OS | ||
apt: | ||
name: git | ||
state: present | ||
|
||
|
||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
#- name: allow ports in ufw | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove rather than keep commented out if not being used |
||
# ufw: | ||
# rule: allow | ||
# port: "{{ item }}" | ||
# with_items: "{{ allowed_ports != '' }}" | ||
# notify: | ||
# - reload ufw | ||
#- name: deny ports in ufw | ||
# ufw: | ||
# rule: deny | ||
# port: "{{ item }}" | ||
# with_items: "{{ denied_ports }}" | ||
# notify: | ||
# - reload ufw |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
- name: deploy sshd config | ||
template: | ||
src: sshd_config.j2 | ||
dest: /etc/ssh/sshd_config | ||
backup: yes | ||
owner: root | ||
group: root | ||
mode: 0644 | ||
notify: | ||
- restart sshd |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
#- name: enable ufw | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How come not enabling ufw? |
||
# ufw: | ||
# state: enabled | ||
#- name: allow openssh | ||
# ufw: | ||
# rule: allow | ||
# name: OpenSSH | ||
#notify: | ||
# - reload ufw |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
- name: accept ufw forwarding policy | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Better to reuse the 'common' role and extend it - because introducing this results in duplicate files |
||
replace: | ||
dest: /etc/default/ufw | ||
backup: yes | ||
regexp: ^DEFAULT_FORWARD_POLICY="DROP" | ||
replace: DEFAULT_FORWARD_POLICY="ACCEPT" | ||
notify: | ||
- reload ufw | ||
|
||
- name: add docker network to ufw before.rules | ||
blockinfile: | ||
dest: /etc/ufw/before.rules | ||
backup: yes | ||
insertbefore: "^[*]filter" | ||
marker: "# {mark} ANSIBLE MANAGED BLOCK" | ||
block: | | ||
*nat | ||
:POSTROUTING ACCEPT [0:0] | ||
-A POSTROUTING ! -o docker0 -s 172.17.0.0/16 -j MASQUERADE | ||
COMMIT | ||
notify: | ||
- reload ufw |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
# tasks file for ../basic/ | ||
|
||
- include: debian.yml | ||
when: ansible_os_family == "Debian" | ||
|
||
- include: rpm.yml | ||
when: ansible_distribution == "CentOS" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
|
||
#- include: rpm_based/add_swapspace.yml | ||
- include: rpm_based/sshd_config.yml | ||
|
||
- name: installing vim for rpm based OS | ||
yum: | ||
name: vim | ||
state: present | ||
|
||
- name: installing git for rpm based OS | ||
yum: | ||
name: git | ||
state: present | ||
|
||
- name: installing git for rpm based OS | ||
yum: | ||
name: git | ||
state: present |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
- name: check if swap space has been configured | ||
stat: | ||
path: /swapfile | ||
register: swap_status | ||
|
||
- name: setup 4Gb swap space | ||
command: dd if=/dev/zero of=/swapfile bs=1024 count=4096k && mkswap /swapfile | ||
when: not swap_status.stat.exists | ||
|
||
- name: activate swap space | ||
command: sudo swapon /swapfile && echo '/swapfile swap swap defaults 0 0' | sudo tee --append /etc/fstab | ||
when: not swap_status.stat.exists |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
- name: disable root login | ||
lineinfile: | ||
dest: /etc/ssh/sshd_config | ||
regexp: '^PermitRootLogin' | ||
line: 'PermitRootLogin no' | ||
state: present | ||
notify: restart sshd | ||
|
||
- name: disable password authentication | ||
lineinfile: | ||
dest: /etc/ssh/sshd_config | ||
regexp: '^PasswordAuthentication' | ||
line: 'PasswordAuthentication no' | ||
state: present | ||
notify: restart sshd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we specifying ports 8080 here? Port 22 is also defined in the code that enables ufw (look for OpenSSH)
Also looking at the 'basic' role, seems that ufw is not enabled...