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

cove-oc4ids Ubuntu upgrade #404

Merged
merged 26 commits into from
Feb 24, 2023
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
dde2629
feat: Configuring new cove_oc4ids server
Jan 18, 2023
6c9e1e8
feat: Adding networkd support
Jan 18, 2023
066f5ca
feat: Adding Ubuntu 22 OS support
Jan 18, 2023
a413035
refactor: iptables location lookup code
Jan 18, 2023
9f0d2cd
fix: implement virtualenv permissions workaround
Jan 18, 2023
c13b743
fix: adding new libffi-dev dependencies
Jan 18, 2023
b84dc45
feat!: Updating URLs for direct access
Jan 18, 2023
6d48e2f
chore: Applying shellcheck feedback
Jan 18, 2023
47aa2c6
chore: Applying shfmt feedback
Jan 18, 2023
bb89b5f
chore: Updating RKHunter configuration
Jan 18, 2023
8da8a1e
refactor: changing servername
Jan 23, 2023
56afb33
feat: enable uwsgi settings
Jan 23, 2023
911f196
doc: adding systemd-networkd configuration
Jan 24, 2023
55423a8
docs: Remove /infrastructure/review and redirect to new subdomain
jpmckinney Jan 24, 2023
eed83e7
docs: Remove a couple more mentions of infrastructure/review
jpmckinney Jan 24, 2023
5900b8b
network: Rename .template to .network to match final file extension
jpmckinney Jan 24, 2023
3933d80
refactor: integer comparison rather than string
Feb 21, 2023
d5a2040
refactor: install libffi-dev with extensions
Feb 21, 2023
8a52c99
docs: Copy-edit networking docs
jpmckinney Feb 21, 2023
b7caba6
refactor: hardcode gateway6 variable
Feb 21, 2023
5dca666
Merge branch 'cove-ubuntu-20' of github.com:open-contracting/deploy i…
Feb 21, 2023
7cde79c
docs: Remove extra space
jpmckinney Feb 21, 2023
07cebdc
fix: limit django configuration for older systems
Feb 22, 2023
b85af3d
feat: deploy new ocds server
Feb 24, 2023
7dbfa75
fix: allow homedir access
Feb 24, 2023
94cab10
chore: add new instances in prometheus
Feb 24, 2023
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
1 change: 0 additions & 1 deletion docs/develop/update/apache.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ Add to your service's Pillar file:
serveraliases: ['live.standard.open-contracting.org']
context:
ocds_cove_backend: https://cove.live3.cove.opencontracting.uk0.bigv.io
oc4ids_cove_backend: https://cove-live.oc4ids.opencontracting.uk0.bigv.io
timeout: 1830 # 30 sec longer than cove's uwsgi.harakiri

This will:
Expand Down
63 changes: 45 additions & 18 deletions docs/develop/update/network.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,30 @@ Update the server's Pillar file:

``ipv6`` is optional.

Netplan
-------
Linux networking
----------------

`Netplan <https://netplan.io>`__ uses YAML files for configuration. Configurations are available for Linode and other hosts. The configuration is written to ``/etc/netplan/10-salt-networking.yaml``.
systemd-networkd
~~~~~~~~~~~~~~~~

`systemd-networkd <https://manpages.ubuntu.com/manpages/jammy/man5/systemd.network.5.html>`__ is a system daemon to configure networking, and is our preferred solution for Linode instances. Configurations are available for `Linode`_ and other hosts. The configuration is written to ``/etc/systemd/network/05-eth0.network``.

Linode
~~~~~~
Linode template
^^^^^^^^^^^^^^^

This configuration disables automatic IP configuration and configures static networking on IPv4 and IPv6.

.. note::

By default, a Linode server listens on – and prefers traffic to – its default IPv6 address. We use our own IPv6 block – ``2a01:7e00:e000:02cc::/64`` – to improve IP reputation and email deliverability.

.. admonition:: One-time setup
.. admonition::

`Open a support ticket with Linode <https://cloud.linode.com/support/tickets>`__ to request an IPv6 /64 block:
`Open a support ticket with Linode <https://cloud.linode.com/support/tickets>`__ to request an IPv6 /64 block, replacing ``ocpXX`` with the Linode instance's ID:

Hello,

Please provision an IPv6 /64 block for our account.
Please can you provision an IPv6 /64 block for my server ocpXX.open-contracting.org.

Thank you,

Expand All @@ -49,28 +52,52 @@ Update the server's Pillar file:
host_id: ocp12
ipv4: 198.51.100.34
ipv6: 2001:db8::12
netplan:
networkd:
template: linode
addresses:
- 2001:db8::32/64 # SLAAC
- 2001:db8::/64
gateway4: 198.51.100.1
gateway6: fe80::1

To fill in the above, from the *Network* tab on the `Linode's <https://cloud.linode.com/linodes>`__ page, collect:

``ipv4``
The *Address* with a *Type* of *IPv4 – Public*
``addresses``
The *Address* with a *Type* of *IPv6 – SLAAC*, `suffixed by "/64" <https://www.linode.com/docs/guides/linux-static-ip-configuration/#general-information>`__
``gateway4``
The *Default Gateway* with a *Type* of *IPv4 – Public*
``gateway6``
The *Default Gateway* with a *Type* of *IPv6 – SLAAC*
``addresses``
Other IP addresses attached to your instance (if any). Include the subnet block suffix, e.g.: `/64`

Custom template
^^^^^^^^^^^^^^^

.. warning::

Only use a ``custom`` template if your needs are not met by any other template.

For ``ipv6``, use our IPv6 block with the hostname's digits as the final group of the IPv6 address: for example, *2a01:7e00:e000:02cc::12* for *ocp12*.
In the server's Pillar file, set ``network.networkd.template`` to ``custom`` and set ``network.networkd.configuration``:

Other hosting providers
~~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: yaml

[Match]
Name=eth0

[Network]
DHCP=no
DNS=203.0.113.1 203.0.113.2 2001:db8::32 2001:db8::64
Domains=open-contracting.org
IPv6PrivacyExtensions=false
IPv6AcceptRA=false

Address=198.51.100.34/24
Address=2001:db8::12/64

Gateway=Address=198.51.100.1
Gateway=fe80::1

Netplan
~~~~~~~

`Netplan <https://netplan.io>`__ uses YAML files for configuration. Configurations are available for Linode and other hosts. The configuration is written to ``/etc/netplan/10-salt-networking.yaml``.

.. note::

Expand Down
2 changes: 1 addition & 1 deletion docs/reference/docs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This page serves as an orientation to how different components of the OCDS docum
Servers
-------

The ``docs`` target serves OCDS documentation (e.g. `1.1 <https://standard.open-contracting.org/1.1/>`__), its profiles (e.g. `Public Private Partnerships <https://standard.open-contracting.org/profiles/ppp/latest/en/>`__) and draft documentation (below). It is a reverse proxy to the `OCDS Data Review Tool <https://standard.open-contracting.org/review/>`__ and the `OC4IDS Data Review Tool <https://standard.open-contracting.org/infrastructure/review/>`__. It also serves Elasticsearch.
The ``docs`` target serves OCDS documentation (e.g. `1.1 <https://standard.open-contracting.org/1.1/>`__), its profiles (e.g. `Public Private Partnerships <https://standard.open-contracting.org/profiles/ppp/latest/en/>`__) and draft documentation (below). It is a reverse proxy to the `OCDS Data Review Tool <https://standard.open-contracting.org/review/>`. It also serves Elasticsearch.

Version and language switchers
------------------------------
Expand Down
12 changes: 10 additions & 2 deletions pillar/cove_oc4ids.sls
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
network:
host_id: ocp17
ipv4: 176.58.112.127
ipv6: "2a01:7e00:e000:04c1::"
This conversation was marked as resolved.
Show resolved Hide resolved
networkd:
template: linode
gateway4: 176.58.112.1

ssh:
root:
# Open Data Services Co-operative
Expand All @@ -10,9 +18,9 @@ python_apps:
url: https://github.com/open-contracting/cove-oc4ids.git
django:
env:
ALLOWED_HOSTS: .standard.open-contracting.org,.oc4ids.opencontracting.uk0.bigv.io
ALLOWED_HOSTS: review-oc4ids.standard.open-contracting.org
FATHOM_ANALYTICS_ID: UHUGOEOK
apache:
servername: cove-live.oc4ids.opencontracting.uk0.bigv.io
servername: review-oc4ids.standard.open-contracting.org
context:
assets_base_url: /infrastructure
10 changes: 10 additions & 0 deletions pillar/cove_oc4ids_maintenance.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
maintenance:
enabled: True
patching: manual
rkhunter_customisation: |
SCRIPTWHITELIST=/usr/bin/egrep
SCRIPTWHITELIST=/usr/bin/fgrep
SCRIPTWHITELIST=/usr/bin/which.debianutils
RTKT_FILE_WHITELIST=/usr/lib/x86_64-linux-gnu/libkeyutils.so.1.9
USER_FILEPROP_FILES_DIRS=/usr/lib/x86_64-linux-gnu/libkeyutils.so.1.9
ALLOW_SSH_ROOT_USER=yes
1 change: 0 additions & 1 deletion pillar/docs.sls
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ apache:
servername: standard.open-contracting.org
context:
ocds_cove_backend: https://cove.live3.cove.opencontracting.uk0.bigv.io
oc4ids_cove_backend: https://cove-live.oc4ids.opencontracting.uk0.bigv.io
timeout: 1830 # 30 sec longer than cove's uwsgi.harakiri

elasticsearch:
Expand Down
1 change: 1 addition & 0 deletions pillar/top.sls
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ base:
'cove-oc4ids':
- cove
- cove_oc4ids
- cove_oc4ids_maintenance
- private.cove_oc4ids
- maintenance

Expand Down
3 changes: 2 additions & 1 deletion salt-config/roster
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Defines the potential targets of the salt-ssh command.

cove-oc4ids: ocp01.open-contracting.org
cove-oc4ids: ocp17.open-contracting.org
cove-ocds: ocp02.open-contracting.org
docs: ocp07.open-contracting.org
kingfisher-process: ocp04.open-contracting.org
Expand All @@ -13,6 +13,7 @@ registry:
port: 2223

# ocp0 was crm.open-contracting.org
# ocp01 was cove-oc4ids on Ubuntu 18
# ocp06 was covid19-dev
# ocp08 was redash.open-contracting.org on Ubuntu 18
# ocp09 was toucan.open-contracting.org
Expand Down
1 change: 0 additions & 1 deletion salt/apache/files/docs/robots.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ Disallow: /legacy
Disallow: /staging
# Disallow Data Review Tool results.
Disallow: /review/data
Disallow: /infrastructure/review/data

User-Agent: LinkChecker
Allow: /
4 changes: 3 additions & 1 deletion salt/apache/files/sites/docs.conf.include
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
'versions': ['latest', '0.9'],
'languages': ['en'],
'redirect_excludes': ['schema'],
'cove_backend': oc4ids_cove_backend,
},
'': {
'versions': ['latest', '1.1', '1.0'],
Expand Down Expand Up @@ -209,6 +208,9 @@ Redirect /profiles/gpa/master /profiles/gpa/latest
# The Validator was renamed the Data Review Tool.
Redirect /validator /review
RedirectMatch ^/validator/(.*)$ /review/$1
# The Data Review Tool was moved to its own subdomain.
Redirect /infrastructure/review /review https://review-oc4ids.standard.open-contracting.org
RedirectMatch ^/infrastructure/review(.*)$ https://review-oc4ids.standard.open-contracting.org/$1

# See: https://crm.open-contracting.org/issues/4401
{% for lang in options[''].languages %}
Expand Down
4 changes: 4 additions & 0 deletions salt/apache/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,22 @@
# ondrej/apache2 is still needed on Ubuntu 20.04 for MDContactEmail.
# https://github.com/icing/mod_md/issues/203
apache2:
{%- if grains.osmajorrelease in ("18", "20") %}
pkgrepo.managed:
- ppa: ondrej/apache2
{%- endif %}
pkg.installed:
- pkgs:
- apache2
{%- if grains.osmajorrelease in ("18", "20") %}
# Avoid "AH01882: Init: this version of mod_ssl was compiled against a newer library (OpenSSL 1.1.1g 21 Apr 2020,
# version currently loaded is OpenSSL 1.1.1 11 Sep 2018) - may result in undefined or erroneous behavior"
# https://github.com/open-contracting/deploy/issues/66#issuecomment-742898193
- libssl1.1
- openssl
- require:
- pkgrepo: apache2
{%- endif %}
service.running:
- name: apache2
- enable: True
Expand Down
4 changes: 4 additions & 0 deletions salt/core/apt/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@
/etc/apt/apt.conf.d/99-connection-timeouts:
file.managed:
- source: salt://core/apt/files/99-connection-timeouts

needrestart:
pkg.removed:
- name: needrestart
27 changes: 8 additions & 19 deletions salt/core/firewall/files/firewall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,31 +64,20 @@ else
fi

echo_verbose "Get iptables location"
if [ "$ID" == "ubuntu" ] && [ "$VERSION_ID" == "20.04" ]; then
case "${ID}_${VERSION_ID}" in
ubuntu_22.04 | ubuntu_20.04 | ubuntu_18.04 | debian_10 | debian_9 | debian_8)
IPTABLESSAVLOC=/etc/iptables/rules.v4
IP6TABLESSAVLOC=/etc/iptables/rules.v6
elif [ "$ID" == "ubuntu" ] && [ "$VERSION_ID" == "18.04" ]; then
IPTABLESSAVLOC=/etc/iptables/rules.v4
IP6TABLESSAVLOC=/etc/iptables/rules.v6
elif [ "$ID" == "ubuntu" ] && [ "$VERSION_ID" == "16.04" ]; then
IPTABLESSAVLOC=/etc/iptables/rules.v4
IP6TABLESSAVLOC=/etc/iptables/rules.v6
elif [ "$ID" == "debian" ] && [ "$VERSION_ID" == "8" ]; then
IPTABLESSAVLOC=/etc/iptables/rules.v4
IP6TABLESSAVLOC=/etc/iptables/rules.v6
elif [ "$ID" == "debian" ] && [ "$VERSION_ID" == "7" ]; then
IPTABLESSAVLOC=/etc/iptables/rules.v4
IP6TABLESSAVLOC=/etc/iptables/rules.v6
elif [ "$ID" == "centos" ] && [ "$VERSION_ID" == "7" ]; then
IPTABLESSAVLOC=/etc/sysconfig/iptables
IP6TABLESSAVLOC=/etc/sysconfig/ip6tables
elif [ "$ID" == "redhat-derivative" ]; then
;;
centos_7 | redhat-derivative_)
IPTABLESSAVLOC=/etc/sysconfig/iptables
IP6TABLESSAVLOC=/etc/sysconfig/ip6tables
else
;;
*)
echo "Failed to determine iptables location! Please update this script appropriately."
exit 7
fi
;;
esac

if [ "$MONITOR_APPBEAT" == "yes" ]; then
echo_verbose "Get AppBeat IP addresses"
Expand Down
4 changes: 2 additions & 2 deletions salt/core/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ git:
- name: git

# Required for salt to interact with apt.
python-apt:
python3-apt:
pkg.installed:
- name: python-apt
- name: python3-apt

# Required for some targets.
debconf-utils:
Expand Down
1 change: 1 addition & 0 deletions salt/core/network/files/networkd_custom.network
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{ pillar.network.networkd.configuration }}
20 changes: 20 additions & 0 deletions salt/core/network/files/networkd_linode.network
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[Match]
Name=eth0

[Network]
DHCP=no
DNS=178.79.182.5 176.58.107.5 176.58.116.5 176.58.121.5 151.236.220.5 212.71.252.5 212.71.253.5 109.74.192.20 109.74.193.20 109.74.194.20 2a01:7e00::9 2a01:7e00::3 2a01:7e00::c 2a01:7e00::5 2a01:7e00::6 2a01:7e00::8 2a01:7e00::b 2a01:7e00::4 2a01:7e00::7 2a01:7e00::2
Domains=open-contracting.org
IPv6PrivacyExtensions=false
IPv6AcceptRA=false

Address={{ pillar.network.ipv4 }}/24
{%- if 'ipv6' in pillar.network %}
Address={{ pillar.network.ipv6 }}/64
{%- endif %}
{%- for address in pillar.network.networkd.get('addresses', []) %}
Address={{ address }}
{%- endfor %}

Gateway={{ pillar.network.networkd.gateway4 }}
Gateway=fe80::1
17 changes: 16 additions & 1 deletion salt/core/network/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,22 @@ set hostname:
- onchanges:
- file: /etc/mailname

{%- if 'netplan' in pillar.network %}
{%- if 'networkd' in pillar.network %}
/etc/netplan/01-netcfg.yaml:
file.absent

/etc/netplan/01-eth0.yaml:
file.absent

/etc/systemd/network/05-eth0.network:
file.managed:
- source: salt://core/network/files/networkd_{{ pillar.network.networkd.template }}.network
- template: jinja

systemd-networkd:
service.enabled:
- name: systemd-networkd
{%- elif 'netplan' in pillar.network %}
/etc/netplan/01-netcfg.yaml:
file.absent

Expand Down
1 change: 1 addition & 0 deletions salt/python/extensions.sls
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ python c extensions:
- pkgs:
- python3-dev
- build-essential
- libffi-dev
3 changes: 3 additions & 0 deletions salt/python_apps.sls
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ include:
- system_site_packages: False
- pip_pkgs:
- pip-tools
# A Salt bug causes the "user" parameter to be ignored when installing pip packages. Setting "runas" workaround.
# https://github.com/saltstack/salt/issues/59088#issuecomment-912148651
- runas: {{ entry.user }}
- require:
- pkg: virtualenv
- git: {{ entry.git.url }}
Expand Down
7 changes: 5 additions & 2 deletions salt/uwsgi/files/django.ini
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
[uwsgi]
; https://www.techatbloomberg.com/blog/configuring-uwsgi-production-deployment/
; strict = true errors due to deb-confname in /usr/share/uwsgi/conf/default.ini
This conversation was marked as resolved.
Show resolved Hide resolved
; master = true is set in /usr/share/uwsgi/conf/default.ini
; https://uwsgi-docs.readthedocs.io/en/latest/WSGIquickstart.html#a-note-on-python-threads
; https://uwsgi-docs.readthedocs.io/en/latest/Configuration.html
; https://docs.djangoproject.com/en/3.2/howto/deployment/wsgi/uwsgi/

plugin = python3
strict = true
master = true

enable-threads = true
vacuum = true
single-interpreter = true
Expand Down