Skip to content

Commit

Permalink
Update ansible requirements, remove become for localhost delegated …
Browse files Browse the repository at this point in the history
…tasks (LemmyNet#188)

* Add ansible-core >= 2.11.0 requirement
- Adds assertion to gracefully fail instead of an error (ref LemmyNet#177)
- Add to README

* Remove `become` on `localhost` to `lemmy-almalinux.yml` playbook
- Refs LemmyNet#178

* Adjust Ansible -> ansible-core
- Add `become: false` to assertion in `lemmy.yml`

* Adjust README verbiage

* Apparently I really want it to be 2.10.0
  • Loading branch information
codyro authored and snowe2010 committed Jan 30, 2024
1 parent 42eff8f commit 8fb73ec
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ To run this ansible playbook, you need to:
- Have a Debian/AlmaLinux 9-based server / VPS where lemmy will run.
- Configure a DNS `A` Record to point at your server's IP address.
- Make sure you can ssh to it, with a sudo user: `ssh <your-user>@<your-domain>`
- Install [Ansible](https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html) on your **local** machine (do not install it on your destination server).
- Install [Ansible](https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html) (>= `2.11.0` on your **local** machine (do not install it on your destination server).

### Supported Distribution Playbook Matrix

Expand Down
12 changes: 12 additions & 0 deletions lemmy-almalinux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
vars_files:
- "inventory/host_vars/{{ domain }}/vars.yml"
pre_tasks:
- name: Assert that Ansible version is >= 2.11.0
delegate_to: localhost
ansible.builtin.assert:
that:
- "ansible_version.full is version('2.11.0', '>=')"
fail_msg: "This playbook requires Ansible 2.11.0 or higher"
become: false

# This is not needed for this playbook as it predates its existence
# But we're keeping it for funsies :)
- name: Check lemmy_base_dir
Expand All @@ -17,6 +25,7 @@
ansible.builtin.stat:
path: "inventory/host_vars/{{ domain }}/passwords/postgres"
register: postgres_password_file
become: false

- name: Legacy use of passwords/postgres file
delegate_to: localhost
Expand All @@ -25,12 +34,14 @@
In current versions of the Lemmy Ansible playbooks, the passwords/postgres file must be renamed to passwords/postgres.psk.
See https://github.com/LemmyNet/lemmy-ansible#upgrading
when: postgres_password_file.stat.exists
become: false

- name: Check for vars.yml file
delegate_to: localhost
ansible.builtin.stat:
path: "inventory/host_vars/{{ domain }}/vars.yml"
register: vars_file
become: false

- name: Missing vars.yml file
delegate_to: localhost
Expand All @@ -39,6 +50,7 @@
Missing vars.yml file, please refer to the installations instructions. See https://github.com/LemmyNet/lemmy-ansible#install
and https://github.com/LemmyNet/lemmy-ansible#upgrading
when: not vars_file.stat.exists
become: false
handlers:
- name: Reload nginx
ansible.builtin.systemd:
Expand Down
8 changes: 8 additions & 0 deletions lemmy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
vars_files:
- "inventory/host_vars/{{ domain }}/vars.yml"
pre_tasks:
- name: Assert that Ansible version is >= 2.11.0
delegate_to: localhost
ansible.builtin.assert:
that:
- "ansible_version.full is version('2.11.0', '>=')"
fail_msg: "This playbook requires Ansible 2.11.0 or higher"
become: false

- name: Check lemmy_base_dir
ansible.builtin.fail:
msg: "`lemmy_base_dir` is unset. if you are upgrading from an older version, add `lemmy_base_dir=/lemmy` to your inventory file."
Expand Down

0 comments on commit 8fb73ec

Please sign in to comment.