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

Upgrade CONSUL DEMOCRACY installer to version 2.1.1 #19

Merged
merged 36 commits into from
Jul 16, 2024
Merged

Conversation

microweb10
Copy link
Member

Objectives

Upgrade CONSUL DEMOCRACY installer to version 2.1.1 🎉

Check major changes here

Senen and others added 30 commits October 11, 2023 14:10
With this change, we will run Debian tests in separate workflows by
version, so if one job from a Debian version fails, it does not cancel
all the other jobs.

We keep the failing buster tests because the installer works fine on
real servers. It only fails in the CI.
…ly_split_debian_tests

Split Debian tests by Debian version
…an_buster

Drop support for Debian 10 (Buster)
We're going to release version 2.1.0 with many changes that aren't
compatible with Consul Democracy 2.0.1, so we're creating this branch in
order to merge those changes and keep them there until we release Consul
Democracy 2.1.0.
…f nodejs

Note we aren't installing the `master` branch (for now) because that
branch requires configuring Puma with systemd. Instead, we're using the
last commit which still uses Puma as a daemon.
Consul Democracy has added a `.node-version` file in version 2.1.0, and
now it installs the version defined there when deploying with Capistrano
and installs NPM packages for that version.

So we're doing the same when running the installer.
```
[DEPRECATION WARNING]: "include" is deprecated, use include_tasks/import_tasks instead. See https://docs.ansible.com/ansible-core/2.15/user_guide/playbooks_reuse_includes.html for
details. This feature will be removed in version 2.16. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
```
We found nodejs binaries from `nodejs.org/dist` sometimes are not
available or takes to long to download them making the installer
crash.

With this change we hope to significally reduce the chance to have a
failure when running the installer.
…pecific_nodejs_version

Install specific nodejs version
The `puma.service` file included here is an adaptation of the ERB
template provided by the capistrano3-puma gem. In order to transition
smoothly from the systemd configuration generated by this installer to
the systemd configuration provided by capistrano3-puma, the
`puma_service_unit_name` must be the same during both installation and
deployment.

Note that, now that Puma starts with systemd, we have to wait till it
creates a socket before continuing; otherwise the socket file won't be
there when we execute the next command, and that command will file.

Also note we have to configure the XDG_RUNTIME_DIR variable. Quoting the
ansible documentation [1]:

> For systemd to work with ‘user’, the executing user must have its own
> instance of dbus started and accessible (systemd requirement).
>
> The user dbus process is normally started during normal login, but not
> during the run of Ansible tasks. Otherwise you will probably get a
> 'Failed to connect to bus: no such file or directory' error.
>
> The user must have access, normally given via setting the
> XDG_RUNTIME_DIR variable.

We also need to check for systemd access because ansible doesn't do it
automatically [2]. In order to allow unprivileged users to enable
lingering to enable systemd user units, we need to install the
policykit-1 package, which is installed by default in Ubuntu but not on
Debian Bookworm. Without this package the action of lingering requires
sudo priveleges.

Finally, we're using Consul Democracy's `master` branch, since it
contains support for Puma with Systemd.

[1] https://docs.ansible.com/ansible/latest/collections/ansible/builtin/systemd_service_module.html#parameter-scope
[2] See issue in 72674 https://github.com/ansible/ansible/issues/

Co-Authored-By: Senén Rodero <[email protected]>
While this isn't needed when starting the Puma service on the server or
with Capistrano, we need the RVM script while using the installer.

The file is now different from the one generated by capistrano3-puma,
but that's alright because it will be overwritten when deploying with
Capistrano (as long as the `:puma_service_unit_name` is the same).
The Docker images for Debian don't include systemd and, even when using
an image that comes with support with systemd [1], we're getting a
warning when starting Puma (the following error takes place when we skip
the "Enable systemd access" step, since that step also raises an error
in Debian):

> Warning: : daemon-reload failed, but target is a chroot or systemd
> is offline.
> Continuing. Error was: 1 / Failed to connect to bus: No such file or
> directory
> Warning: : Target is a chroot or systemd is offline. This can
> lead to false positives or prevent the init system tools from working.

So Puma isn't started in this case.

So now Debian support is uncertain, since we aren't able to test that
Puma starts correctly and the web is accessible. We're at least testing
that the rest of the installation process runs correctly.

[1] https://github.com/trfore/docker-debian11-systemd/blob/main/Dockerfile
1. Errbit does not have the mongodb package available via apt.
2. The latest Errbit version uses ruby 2.7.4 which needs SSL1 while Ubuntu 22.04 supports SSL3.
For some reason I do not know yet, when running the installer on a
Ubuntu 22.04 server it creates the deploy_user home directory with 750 permissions instead of 755.

We need 755 permissions so other users like `www-data`, which runs the nginx service can read from the Consul Democracy puma socket. Otherwise we get a 502 Bad Gateway error when accessing the application.
…u_22.04_support

Add Ubuntu 22.04 support
Since Bookworm comes with PostgreSQL 15, we need to make the
`deploy_user` the database owner. Quoting the PostgreSQL 15 release
notes [1]:

> PostgreSQL 15 also revokes the CREATE permission from all users
> except a database owner from the public (or default) schema.

Now, we first create the user without any privileges, then create the
database with the new user as the database owner and finally grant
all privileges to the new user on the new database.

[1] https://www.postgresql.org/about/news/postgresql-15-released-2526/

Co-Authored-By: Senén Rodero <[email protected]>
…on_timezone

Set the application timezone
Now it's disabled through environment variable.
…et_activation

Enable graceful appication restarts
javierm and others added 6 commits February 20, 2024 20:53
We renamed the `tests` workflow to `ubuntu` in commit f346954, when we
added support for Debian, but forgot to update the badge.

Note that we're only adding the build status on Ubuntu because the
status badge for the Debian build is shown as failing even when tests
are passing. Since we're about to release version 2.1.1, we're leaving
it like that for now, but ideally we'll add the Debian badge in the
future as well.
…ge_update

Update tests status badge in README
….1.1

Install Consul Democracy version 2.1.1
@microweb10 microweb10 merged commit 801a3ea into master Jul 16, 2024
10 checks passed
@microweb10 microweb10 deleted the release_2.1.1 branch July 16, 2024 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants