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 Ubuntu] changes for uk_staging2 #937

Merged
merged 11 commits into from
Oct 8, 2024

Conversation

dacook
Copy link
Member

@dacook dacook commented Sep 12, 2024

ansible-playbook playbooks/fetch_secrets.yml
ansible-playbook site.yml --limit=uk_staging2  -e "ansible_user=ubuntu"

Documentation

Updated:

I guess the two versions were required during a transition period. All servers have been running 3.1.4 for a while now so that's all we should need.
It is a thousand times more readable than the default JSON format.
And thus use Postgres 12 which is packaged with Ubuntu 20.
@dacook dacook self-assigned this Sep 12, 2024
@dacook dacook changed the title Uk staging2 [Upgrade Ubuntu] uk_staging2 Sep 12, 2024
@dacook

This comment was marked as resolved.

@dacook

This comment was marked as resolved.

@mkllnk

This comment was marked as resolved.

@dacook

This comment was marked as resolved.

@dacook

This comment was marked as resolved.

@dacook dacook mentioned this pull request Sep 18, 2024
7 tasks
@mkllnk

This comment was marked as resolved.

@dacook
Copy link
Member Author

dacook commented Sep 19, 2024

✅ Successful deployment now, after restarting and re-provisioning with the multi_redis role.

ansible-playbook playbooks/deploy.yml --limit=uk_staging2
...
staging2.openfoodnetwork.org.uk : ok=31   changed=18   unreachable=0    failed=0    skipped=7    rescued=0    ignored=0

Now to provision ofn-security. It went so well.. until right at the end:

~/projects/ofn-security $ ansible-playbook playbooks/provision.yml --limit uk_staging2
...
RUNNING HANDLER [suricata : reload suricata rules] *********************************************************************
fatal: [staging2.openfoodnetwork.org.uk]: FAILED! => {"changed": true, "cmd": ["pkill", "-USR2", "--pidfile", "/var/run/suricata.pid"], "delta": "0:00:00.010499", "end": "2024-09-19 02:03:09.584525", "msg": "non-zero return code", "rc": 1, "start": "2024-09-19 02:03:09.574026", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}

It was left in "exited" state which doesn't sound good. So I manually restarted (which is the next step anyway)

ofn-admin@ov-a4c948:~$ systemctl status suricata
● suricata.service - LSB: Next Generation IDS/IPS
     Loaded: loaded (/etc/init.d/suricata; generated)
     Active: active (exited) since Thu 2024-09-19 02:00:06 UTC; 1h 9min ago
...
ofn-admin@ov-a4c948:~$ systemctl status suricata
● suricata.service - LSB: Next Generation IDS/IPS
     Loaded: loaded (/etc/init.d/suricata; generated)
     Active: active (running) since Thu 2024-09-19 03:11:44 UTC; 5s ago

ofn-admin@ov-a4c948:~$ tail -n1 /var/log/suricata/suricata.log
[47922 - Suricata-Main] 2024-09-19 03:11:57 Notice: threads: Threads created -> W: 2 FM: 1 FR: 1   Engine started.

🤷 I'm not sure exactly what the "reload suricata rules" task is trying to do, but if suricata is functioning then I don't want to investigate!

@dacook
Copy link
Member Author

dacook commented Sep 19, 2024

The host_id variable is only used for the new relic data. I'd like to :

  • rename to match the new ansible host names (with underscore instead of dash)
  • add a provision task to set the server hostname with it (it would be really handy to help make clear which server you're connected to)

@dacook dacook added the pr-staged-uk https://staging.openfoodnetwork.org.uk/ label Sep 24, 2024
And documentation, wow what a difference it could make.
This makes it much clearer when you SSH into the machine. I wanted to also changed the host_id to use an underscore, like uk_staging, to match our inventory names. But apparently underscores are not allowed for hostnames. And dashes are not allowed in ansible inventory names.
@dacook

This comment was marked as resolved.

@mkllnk

This comment was marked as resolved.

@dacook

This comment was marked as resolved.

The service_facts task was failing on uk_staging2. Dunno why, but I don't think we need any of this anymore.
It was a safety check for when deploying to an old version of OFN, but I dont' think we need to handle that gracefully anymore.
@dacook
Copy link
Member Author

dacook commented Oct 8, 2024

For reference, here's the error occurring for ansible built-in command service_facts:
fatal: [staging.openfoodnetwork.org.uk]: FAILED! => {"changed": false, "msg": "Malformed output discovered from systemd list-unit-files: accounts-daemon.service enabled enabled "}

Due to: ansible/ansible#68536
This is fixed in Ansible v2.10.

I'm sure it will catch someone out one day.
If this works, probably also need to apply it in roles/webserver/handlers/main.yml
@dacook dacook marked this pull request as ready for review October 8, 2024 06:06
@dacook dacook removed the pr-staged-uk https://staging.openfoodnetwork.org.uk/ label Oct 8, 2024
@dacook
Copy link
Member Author

dacook commented Oct 8, 2024

Although I'm not quite finished with uk_staging server, I think it's high time this PR is reviewed.
If further changes are required for metabase, I'll raise a new PR.

Copy link
Member

@mkllnk mkllnk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work.

Comment on lines -14 to -15
- name: run preflight checks
include_tasks: preflight_checks.yml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call.

Comment on lines 60 to 63
ruby_versions:
- version: 2.7.3
env:
RUBY_CONFIGURE_OPTS: "{{ ruby_compile_options }}"
- version: 3.0.3
- version: 3.1.4
env:
RUBY_CONFIGURE_OPTS: "{{ ruby_compile_options }}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good one. New Ruby versions are now automatically installed during deploys. So we don't need to run Ansible for that. This is just for the initial version.

I wish that we could skip the version and take the version number from the ofn code but this role requires a version. So if we want to set up rbenv without installing ruby straight away then we can't use this role. Just one of the annoying Ansible things that we could replace with shell scripts...

Copy link
Contributor

@rioug rioug left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one !

@rioug rioug merged commit 8fc3d45 into openfoodfoundation:master Oct 8, 2024
2 checks passed
@dacook dacook changed the title [Upgrade Ubuntu] uk_staging2 [Upgrade Ubuntu] changes for uk_staging2 Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants