freephile / meza

Setup an enterprise MediaWiki server with simple commands
MIT License
0 stars 0 forks source link

Upgrade Ansible #51

Open freephile opened 7 months ago

freephile commented 7 months ago

Ansible, Python (issue #41) and RockyLinux (issue #31) for a new foundation.

freephile commented 1 month ago

pip3 install --user "ansible<10.0"

ansible --version
[DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the controller starting with Ansible 2.12. Current version: 3.6.8 (default, Apr 24 2024, 21:55:04) [GCC 8.5.0 
20210514 (Red Hat 8.5.0-22)]. This feature will be removed from ansible-core in version 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in 
ansible.cfg.
ansible [core 2.11.12] 
  config file = /opt/meza/config/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.6/site-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.6.8 (default, Apr 24 2024, 21:55:04) [GCC 8.5.0 20210514 (Red Hat 8.5.0-22)]
  jinja version = 2.10.1
  libyaml = True
freephile commented 1 month ago

Even after installing the ansible.posix collection ansible-galaxy collection install ansible.posix, a deploy will fail with

 meza deploy monolith -vvv
Create deploy lock file at /opt/data-meza/env-monolith-deploy.lock
Group apache does not exist. Set "wheel" as group for lock file.
su meza-ansible -c "ansible-playbook /opt/meza/src/playbooks/site.yml -i /opt/conf-meza/secret/monolith/hosts --vault-password-file /opt/conf-meza/vault/vault-pass-monolith.txt --extra-vars '{\"env\": \"monolith\"}' -vvv"
[DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the 
controller starting with Ansible 2.12. Current version: 3.6.8 (default, Apr 24 
2024, 21:55:04) [GCC 8.5.0 20210514 (Red Hat 8.5.0-22)]. This feature will be 
removed from ansible-core in version 2.12. Deprecation warnings can be disabled
 by setting deprecation_warnings=False in ansible.cfg.
ansible-playbook [core 2.11.12] 
  config file = /opt/meza/config/ansible.cfg
  configured module search path = ['/opt/conf-meza/users/meza-ansible/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.6/site-packages/ansible
  ansible collection location = /opt/conf-meza/users/meza-ansible/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible-playbook
  python version = 3.6.8 (default, Apr 24 2024, 21:55:04) [GCC 8.5.0 20210514 (Red Hat 8.5.0-22)]
  jinja version = 2.10.1
  libyaml = True
Using /opt/meza/config/ansible.cfg as config file
host_list declined parsing /opt/conf-meza/secret/monolith/hosts as it did not pass its verify_file() method
script declined parsing /opt/conf-meza/secret/monolith/hosts as it did not pass its verify_file() method
auto declined parsing /opt/conf-meza/secret/monolith/hosts as it did not pass its verify_file() method
Parsed /opt/conf-meza/secret/monolith/hosts inventory source with ini plugin
redirecting (type: modules) ansible.builtin.authorized_key to ansible.posix.authorized_key
ERROR! couldn't resolve module/action 'authorized_key'. This often indicates a misspelling, missing collection, or incorrect module path.

The error appears to be in '/opt/meza/src/roles/base/tasks/main.yml': line 37, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

- name: Set authorized key for alt-meza-ansible
  ^ here

Because, the meza-ansible user does not have the same collections path as the 'root' user (and it wasn't installed to the system-wide /usr/share/ansible/collections path).

For meza-ansible user, this is the collection location:

ansible collection location = /opt/conf-meza/users/meza-ansible/.ansible/collections:/usr/share/ansible/collections
freephile commented 1 month ago

The proper solution to A) installing the various collections that Meza is dependent upon B) ensuring the proper version of Ansible and ansible binaries are installed on a target is to create a requirements.yml file that lists the collections as well as an updated ansible.cfg that specifies that the collections are located within the project's code directory (ignored by git since they are 'vendored' code).

These code additions were made

They just need to be factored into an updated getmeza.sh

freephile commented 1 week ago
[meza-ansible@rockylinux-s-4vcpu-8gb-nyc3-01 config]$ ansible --version
ansible [core 2.16.3]
  config file = /opt/meza/config/ansible.cfg
  configured module search path = ['/opt/conf-meza/users/meza-ansible/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.12/site-packages/ansible
  ansible collection location = /opt/meza/collections
  executable location = /usr/bin/ansible
  python version = 3.12.5 (main, Sep 24 2024, 09:41:18) [GCC 8.5.0 20210514 (Red Hat 8.5.0-22)] (/usr/bin/python3.12)
  jinja version = 3.1.2
  libyaml = True