Skip to content
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

Feature/firewall #581

Merged
merged 26 commits into from
Jun 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
00db6d9
Renamed and relocated iptables configuration related files.
pneerincx Jan 7, 2020
d0793b2
Additional work on iptables role and corresponding variables for test…
pneerincx Jan 7, 2020
aa2915c
Renamed and relocated iptables configuration related files.
pneerincx Jan 7, 2020
86fc307
Additional work on iptables role and corresponding variables for test…
pneerincx Jan 7, 2020
610f18b
Merge branch 'feature/firewall' of https://github.com/pneerincx/leagu…
pneerincx Apr 28, 2022
f0a9fd3
Merged changes from develop branch into this feature/firewall branch …
pneerincx Apr 28, 2022
0f26ca8
Merge branch 'develop' into feature/firewall
pneerincx May 12, 2022
65ad72b
Added new IP for UMCG Basis Werkplek VMs.
pneerincx May 13, 2022
47320aa
Merge branch 'develop' into feature/firewall
pneerincx May 13, 2022
0a89256
Merge branch 'develop' into feature/firewall
pneerincx May 13, 2022
2d003ab
Merge branch 'develop' into feature/firewall
pneerincx May 18, 2022
58ea221
Added umcg_net4 to totp for Winged Helix.
pneerincx May 19, 2022
ee9755b
Merge branch 'develop' into feature/firewall
pneerincx May 27, 2022
96c2678
Deleted group_vars/marvin_cluster/ip_addresses.yml as cluster is offl…
pneerincx Jun 7, 2022
2cf8159
Refactored structure used in ip_addresses.yml files: added support fo…
pneerincx Jun 7, 2022
958359e
Remove trailing "$" (dollar sign) in network share names. This is use…
pneerincx Jun 7, 2022
2d356fd
Added new single_role_playbooks/irods_davrods.yml
pneerincx Jun 7, 2022
07a19a6
Re-added static_inventories/calculon_cluster.yml, which was lost in t…
pneerincx Jun 7, 2022
8caf48f
Bugfixes.
pneerincx Jun 7, 2022
e7943c2
Updated ansible-lint and circle_ci configs.
pneerincx Jun 8, 2022
405bd59
Fixed YAML lint issues.
pneerincx Jun 8, 2022
460efc2
Updated .ansible-lint: skip experimental rules.
pneerincx Jun 8, 2022
1bb0b9e
Renamed galaxy-requirements.yml -> requirements.yml (default name for…
pneerincx Jun 8, 2022
e98b130
Fixed linter issues.
pneerincx Jun 8, 2022
f67821f
Added README for include_vars_from_other_groups role.
pneerincx Jun 8, 2022
048cfd9
Added README for include_vars_from_other_groups role.
pneerincx Jun 8, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .ansible-lint
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
exclude_paths:
- '~/.ansible' # Exclude external playbooks.
skip_list:
# We explicitly use latest combined with other tech to pin versions (e.g. Spacewalk).
# We explicitly use latest combined with other tech to pin versions (e.g. Pulp).
- 'package-latest' # "Package installs should not use latest (403)."
- 'meta-no-info' # "No 'galaxy_info' found in meta/main.yml of a role (701)."
- 'experimental' # All rules tagged as experimental.
...
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ jobs:
command: |
python -m venv venv
. venv/bin/activate
pip install "ansible-lint[community,yamllint]"
ansible-galaxy install -r galaxy-requirements.yml
pip install ansible-lint
ansible-galaxy install -r requirements.yml
- run:
name: run tests
shell: /bin/bash
Expand All @@ -36,7 +36,7 @@ jobs:
else
export ANSIBLE_ROLES_PATH="${HOME}/.ansible/roles/"
fi
if ansible-lint -p --nocolor cluster.yml deploy-os_servers.yml > lint_results 2>&1; then
if ansible-lint -p --nocolor *.yml > lint_results 2>&1; then
lint_errors=0
else
cat lint_results
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ pip3 install mitogen
#### 1. First import the required roles and collections for the playbooks:

```bash
ansible-galaxy install -r galaxy-requirements.yml
ansible-galaxy install -r requirements.yml
```

Note: the default location where these dependencies will get installed with the above command is ```${HOME}/.ansible/```.
Expand Down
36 changes: 2 additions & 34 deletions cluster.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,7 @@
---
#
# Order of deployment required to prevent chicken versus the egg issues:
# 0. For all deployment phases:
# export AI_PROXY="${jumphost_name}"
# export ANSIBLE_INVENTORY="static_inventories/${stack_name}.yml"
# ANSIBLE_VAULT_PASSWORD_FILE=".vault_pass.txt.${stack_name}"
# 1. Use standard CentOS cloud image user 'centos' or 'root' user and without host key checking:
# export ANSIBLE_HOST_KEY_CHECKING=False
# ansible-playbook -u centos -l 'jumphost,cluster' single_role_playbooks/admin_users.yml
# ansible-playbook -u root -l 'docs' single_role_playbooks/admin_users.yml
# 2. Use local admin user's account and without host key checking:
# export ANSIBLE_HOST_KEY_CHECKING=False
# ansible-playbook -u [admin_account] single_role_playbooks/ssh_host_signer.yml
# 3. Use local admin user's account and with strict host key checking to deploy everything else:
# export ANSIBLE_HOST_KEY_CHECKING=True
# ansible-playbook -u [admin_account] cluster.yml
# This will configure:
# * Jumphost first as it is required to access the other machines.
# * Repo management server second as it is required for version control of the packages
# installed on all other machines except for the jumphost, which will always get the latest updates for security.
# * Basic roles for all cluster machines part 1:
# * Roles that do NOT require regular accounts or groups to be present.
# * An LDAP with regular user accounts, which may be required for additional roles.
# (E.g. a chmod or chgrp for a file/folder requires the corresponding user or group to be present.)
# * Basic roles for all cluster machines part 2:
# * Roles that DO depend on regular accounts and groups.
# * SAI as it is required to:
# * Configure layout on shared storage devices used by other machines.
# * Configure Slurm control and Slurm database.
# * DAI
# * UI
# * Compute nodes
# * Documentation server
# See README.md for instructins how to use this playbook.
#

---
#
# Dummy play to ping jumphosts and establish a persisting SSH connection
# before trying to connect to the machines behind the jumphost,
Expand Down
108 changes: 47 additions & 61 deletions create-docs-server.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,13 @@
#
# 1. $> cd git/league-of-robots
# Create Python virtual environment (once)
# 2. $> python3 -m venv openstacksdk.venv
# Activate virtual environment.
# 3. $> source openstacksdk.venv/bin/activate
# Install OpenStack SDK (once).
# 4. $> pip3 install openstacksdk
# $> pip3 install ruamel.yaml
# NOTE: Openstack RC file must be sourced first to be able to use Openstack API from SDK:
# 5. Login to OpenStack web interface -> "Identity" -> "Application Credentials" -> click the "Create Application Credential" button.
# This will result in a popup window: specify "Name", "Expiration Date", "Expiration Time", leave the rest empty / use defaults and
# click the "Create Application Credential" button.
# In the new popup window click the "Download openrc file" button and save the generated *-openrc.sh file in the root of the repo.
# 6. Source the downloaded file. E.g.:
# $> source ./[Application_Credential_Name]-openrc.sh
# 7. Fetch Ansible dependencies
# $> ansible-galaxy install -r galaxy-requirements.yml
# Configure this repo for deployment of a specifc HPC cluster.
# 8. Source lor-init from this repo. E.g.:
# $> source ./lor-init
# 9. Configure League of Robots for a specific cluster. E.g.:
# $> lor-config nb
# 10. Execute playbook to create VMs. E.g.:
# $> ansible-playbook deploy-os_servers.yml
# See README.md for instructins how to use this playbook.
#
---
- name: 'Sanity checks before we start.'
hosts: localhost
connection: local
pre_tasks:
- name: 'Verify Ansible version meets requirements.'
assert:
ansible.builtin.assert:
that: "ansible_version.full is version_compare('2.10', '>=')"
msg: 'You must update Ansible to at least 2.10.x to use this playbook.'
##############################################################################
Expand All @@ -47,6 +24,8 @@
# which would fail to use the interpretor from an activated virtual environment.
#
- ansible_python_interpreter: python
roles:
- include_vars_from_other_groups
tasks:
- name: "Create {{ network_private_management_id }} network."
openstack.cloud.network:
Expand Down Expand Up @@ -104,47 +83,39 @@
Allows all outbound traffic.
wait: true
timeout: "{{ openstack_api_timeout }}"
- name: "Add rule to {{ stack_prefix }}_webservers security group: allow SSH inbound from external jumphost on port 22."
- name: "Add rules to {{ stack_prefix }}_webservers security group: allow inbound SSH from jumphosts."
openstack.cloud.security_group_rule:
security_group: "{{ stack_prefix }}_webservers"
direction: ingress
protocol: tcp
port_range_min: 22
port_range_max: 22
remote_ip_prefix: "{{ ip_addresses[item].addr }}{{ ip_addresses[item].mask }}"
remote_ip_prefix: "{{ remote_ip_address }}{{ remote_ip_netmask }}"
wait: true
timeout: "{{ openstack_api_timeout }}"
with_items: "{{ jumphosts }}"
- name: "Add rule to {{ stack_prefix }}_webservers security group: allow HTTP inbound on port 80."
openstack.cloud.security_group_rule:
security_group: "{{ stack_prefix }}_webservers"
direction: ingress
protocol: tcp
port_range_min: 80
port_range_max: 80
remote_ip_prefix: 0.0.0.0/0
wait: true
timeout: "{{ openstack_api_timeout }}"
- name: "Add rule to {{ stack_prefix }}_webservers security group: allow HTTPS inbound on port 443."
openstack.cloud.security_group_rule:
security_group: "{{ stack_prefix }}_webservers"
direction: ingress
protocol: tcp
port_range_min: 443
port_range_max: 443
remote_ip_prefix: 0.0.0.0/0
wait: true
timeout: "{{ openstack_api_timeout }}"
- name: "Add rule to {{ stack_prefix }}_webservers security group: allow ICMP inbound."
vars:
remote_ip_address: "{{ lookup('vars', item.0.group)['ip_addresses'][item.1.hostname][item.1.network]['address'] }}"
remote_ip_netmask: "{{ lookup('vars', item.0.group)['ip_addresses'][item.1.hostname][item.1.network]['netmask'] }}"
with_subelements:
- "{{ jumphosts }}"
- hosts
- name: "Add rules to {{ stack_prefix }}_webservers security group: allow inbound HTTP(S) and ICMP."
openstack.cloud.security_group_rule:
security_group: "{{ stack_prefix }}_webservers"
direction: ingress
protocol: icmp
port_range_min: -1 # ICMP protocol does not have any ports.
port_range_max: -1 # ICMP protocol does not have any ports.
protocol: "{{ item.protocol }}"
port_range_min: "{{ item.port }}"
port_range_max: "{{ item.port }}"
remote_ip_prefix: 0.0.0.0/0
wait: true
timeout: "{{ openstack_api_timeout }}"
with_items:
- protocol: tcp
port: 80 # HTTP
- protocol: tcp
port: 443 # HTTPS
- protocol: icmp
port: -1 # ICMP protocol does not have any ports.
##############################################################################
# Configure documentation server(s) from inventory using Openstack API.
##############################################################################
Expand All @@ -165,7 +136,7 @@
state: present
name: "{{ inventory_hostname }}"
image: "{{ cloud_image }}"
flavor: "{{ flavor_docs }}"
flavor: "{{ cloud_flavor }}"
security_groups: "{{ stack_prefix }}_webservers"
auto_floating_ip: false
nics:
Expand Down Expand Up @@ -229,18 +200,33 @@
# as filtering directly during the API call is problematic.
# Will filter the results for the relevant servers later on.
#
- name: Get info on floating IPs from OpenStack API.
openstack.cloud.floating_ip_info:
register: api_fip_info
- name: Get info on networks from OpenStack API.
openstack.cloud.networks_info:
register: api_network_info
- name: Get server info from OpenStack API.
openstack.cloud.server_info:
register: api_server_info
- name: "ToDo"
debug:
- name: "Add addresses to {{ playbook_dir }}/group_vars/{{ stack_name }}/ip_addresses.yml.new"
ansible.builtin.template:
src: "{{ playbook_dir }}/group_vars/template/ip_addresses.yml.j2"
dest: "{{ playbook_dir }}/group_vars/{{ stack_name }}/ip_addresses.yml.new"
mode: '0644'
vars:
relevant_servers_list: "{{ groups['docs'] | default([]) }}"
relevant_servers_info: "{{ api_server_info.openstack_servers | selectattr('name', 'in', relevant_servers_list) | list }}"
- name: ToDo
ansible.builtin.debug:
msg: |
***********************************************************************************************************
IMPORTANT: Manual work!
Ansible created:
{{ playbook_dir }}/group_vars/{{ stack_name }}/ip_addresses.yml.new
Please inspect this file carefully with:
diff -y {{ playbook_dir }}/group_vars/{{ stack_name }}/ip_addresses.yml{.new,}
and if Ok execute:
mv {{ playbook_dir }}/group_vars/{{ stack_name }}/ip_addresses.yml{.new,}
***********************************************************************************************************
Check if public IP address "{{ api_server_info.openstack_servers | selectattr('name', 'equalto', item) | map(attribute='accessIPv4') | first }}" for server "{{ item }}"
needs to be updated in:
{{ playbook_dir }}/group_vars/all/ip_addresses.yml
***********************************************************************************************************
with_items: "{{ groups['docs'] | default([]) }}"
...
...
Loading