From 2ecdd0639863d326d7f5f98e49874b6416a92b49 2024-09-09 13:24:10 From: Branko Majic Date: 2024-09-09 13:24:10 Subject: [PATCH] MAR-218: Update the usage tasks and instructions for Ansible 10.3: - Update the module names to include the namespace. - Drop references to Python 3, and bump up the installed package versions. --- diff --git a/docs/usage.rst b/docs/usage.rst index 79fbc966e997dc8e9af7f4c21b52b04568f57c67..7dcb8b6b8b504f1372ae1581125bc2e37dc155ee 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -133,9 +133,9 @@ packages, and to prepare the environment a bit on the Ansible server: :: mkdir ~/mysite/ - mkvirtualenv -p /usr/bin/python3 -a ~/mysite/ mysite + mkvirtualenv -a ~/mysite/ mysite pip install -U pip setuptools - pip install 'ansible~=2.9.0' netaddr + pip install 'ansible~=10.3.0' netaddr .. warning:: The ``netaddr`` package is needed for ``ipv4/ipv6`` lookup plugins @@ -188,7 +188,6 @@ First of all, let's set-up some basic directory structure and configuration: roles_path=/home/ansible/majic-ansible-roles/roles:/home/ansible/mysite/roles force_handlers = True inventory = /home/ansible/mysite/hosts - interpreter_python = /usr/bin/python3 [ssh_connection] pipelining = True @@ -1551,7 +1550,7 @@ Before we start, here is a couple of useful pointers regarding the # ========== - name: Download the application archive - get_url: + ansible.builtin.get_url: url: "https://download.nextcloud.com/server/releases/nextcloud-28.0.3.tar.bz2" dest: "/var/www/nextcloud.example.com/nextcloud-28.0.3.tar.gz" sha256sum: "9ed413c0de16f5b033ceeffcca99c0d61fc698dbeb8db851ac9adf9eef951906" @@ -1559,7 +1558,7 @@ Before we start, here is a couple of useful pointers regarding the become_user: admin-nextcloud_example_com - name: Unpack the application archive - unarchive: + ansible.builtin.unarchive: src: "/var/www/nextcloud.example.com/nextcloud-28.0.3.tar.gz" dest: "/var/www/nextcloud.example.com/" copy: no @@ -1569,23 +1568,23 @@ Before we start, here is a couple of useful pointers regarding the # Majic Ansible Roles currently only support utf8 encoding. - name: Disable opportunistic use of utf8mb4 on fresh installs - lineinfile: + ansible.builtin.lineinfile: dest: "/var/www/nextcloud.example.com/nextcloud/lib/private/Setup/MySQL.php" line: "{{ '\t\t\t' }}$this->config->setValue('mysql.utf8mb4', true);" state: absent - name: Allow application user to install and update applications - file: + ansible.builtin.file: path: "/var/www/nextcloud.example.com/nextcloud/apps" mode: g+w - name: Allow CLI tool to be run by the user and group - file: + ansible.builtin.file: path: "/var/www/nextcloud.example.com/nextcloud/occ" mode: u+x,g+x - name: Create directory for storing data - file: + ansible.builtin.file: path: "/var/www/nextcloud.example.com/data" state: directory mode: 02770 @@ -1593,7 +1592,7 @@ Before we start, here is a couple of useful pointers regarding the group: "web-nextcloud_example_com" - name: Create directory for storing configuration files - file: + ansible.builtin.file: path: "/var/www/nextcloud.example.com/nextcloud/config" state: directory mode: 02750 @@ -1601,20 +1600,20 @@ Before we start, here is a couple of useful pointers regarding the group: "web-nextcloud_example_com" - name: Create an empty log file if it does not exist - copy: + ansible.builtin.copy: content: "" dest: "/var/www/nextcloud.example.com/data/nextcloud.log" force: no - name: Set-up log file permissions - file: + ansible.builtin.file: path: "/var/www/nextcloud.example.com/data/nextcloud.log" owner: "admin-nextcloud_example_com" group: "web-nextcloud_example_com" mode: 0660 - name: Symlink the default path used by the web server for finding application files - file: + ansible.builtin.file: src: "/var/www/nextcloud.example.com/nextcloud" dest: "/var/www/nextcloud.example.com/htdocs" state: link @@ -1628,7 +1627,7 @@ Before we start, here is a couple of useful pointers regarding the # ============ - name: Get application installation status - command: "/var/www/nextcloud.example.com/nextcloud/occ status" + ansible.builtin.command: "/var/www/nextcloud.example.com/nextcloud/occ status" become: yes become_user: "admin-nextcloud_example_com" register: nextcloud_status @@ -1636,11 +1635,11 @@ Before we start, here is a couple of useful pointers regarding the failed_when: False - name: Check if application is installed - set_fact: + ansible.builtin.set_fact: nextcloud_installed: "{{ 'Nextcloud is not installed' not in nextcloud_status.stderr }}" - name: Deploy installation script - copy: + ansible.builtin.copy: src: "install_nextcloud.py" dest: "/var/www/nextcloud.example.com/install_nextcloud.py" owner: "admin-nextcloud_example_com" @@ -1649,25 +1648,25 @@ Before we start, here is a couple of useful pointers regarding the when: "not nextcloud_installed" - name: Install application - command: "/var/www/nextcloud.example.com/install_nextcloud.py" + ansible.builtin.command: "/var/www/nextcloud.example.com/install_nextcloud.py" become: yes become_user: "admin-nextcloud_example_com" when: "not nextcloud_installed" - name: Remove installation script - file: + ansible.builtin.file: path: "/var/www/nextcloud.example.com/install_nextcloud.py" state: absent - name: Fix data file permissions for application user/group - file: + ansible.builtin.file: path: "/var/www/nextcloud.example.com/data" mode: g+w recurse: yes follow: no - name: Deploy local configuration overrides - copy: + ansible.builtin.copy: src: "local.config.php" dest: "/var/www/nextcloud.example.com/nextcloud/config/local.config.php" owner: "admin-nextcloud_example_com" @@ -1928,7 +1927,7 @@ on the safe side: --- - name: Create Django project directory - file: + ansible.builtin.file: dest: "/var/www/wiki.example.com/code" state: directory owner: admin-wiki_example_com @@ -1936,7 +1935,7 @@ on the safe side: mode: 02750 - name: Start Django project for the Wiki website - command: "/var/www/wiki.example.com/virtualenv/bin/exec django-admin startproject wiki_example_com /var/www/wiki.example.com/code" + ansible.builtin.command: "/var/www/wiki.example.com/virtualenv/bin/exec django-admin startproject wiki_example_com /var/www/wiki.example.com/code" args: chdir: "/var/www/wiki.example.com" creates: "/var/www/wiki.example.com/code/wiki_example_com" @@ -1944,7 +1943,7 @@ on the safe side: become_user: admin-wiki_example_com - name: Deploy settings for wiki website - copy: + ansible.builtin.copy: src: "{{ item }}" dest: "/var/www/wiki.example.com/code/wiki_example_com/{{ item }}" mode: 0640 @@ -1957,7 +1956,7 @@ on the safe side: - Restart wiki - name: Deploy project database and deploy static files - django_manage: + community.general.django_manage: command: "{{ item }}" app_path: "/var/www/wiki.example.com/code/" virtualenv: "/var/www/wiki.example.com/virtualenv/" @@ -1968,7 +1967,7 @@ on the safe side: - collectstatic - name: Deploy the superuser creation script - copy: + ansible.builtin.copy: src: "create_superuser.py" dest: "/var/www/wiki.example.com/code/create_superuser.py" owner: admin-wiki_example_com @@ -1976,7 +1975,7 @@ on the safe side: mode: 0750 - name: Create initial superuser - command: "/var/www/wiki.example.com/virtualenv/bin/exec ./create_superuser.py" + ansible.builtin.command: "/var/www/wiki.example.com/virtualenv/bin/exec ./create_superuser.py" args: chdir: "/var/www/wiki.example.com/code/" become: yes @@ -1990,7 +1989,7 @@ on the safe side: --- - name: Restart wiki - service: + ansible.builtin.service: name: wiki.example.com state: restarted @@ -2584,7 +2583,7 @@ easily do so by updating the ``common_packages`` setting. In addition to system packages, the ``common`` role makes it easy to check if any of the pip requirements files are outdated as well. It should be noted, though, that this check does *not* verify the Python virtual environments -themselves. Only Python 3 is supported at this time. +themselves. This is primarily useful when you use `pip-tools `_ for maintaining the