diff --git a/.yamllint b/.yamllint index 7626c6e..894450c 100644 --- a/.yamllint +++ b/.yamllint @@ -9,9 +9,7 @@ rules: max-spaces-inside: 1 level: error line-length: disable - # NOTE(retr0h): Templates no longer fail this lint rule. - # Uncomment if running old Molecule templates. - # truthy: disable + truthy: disable ignore: | .tox/ diff --git a/defaults/main.yml b/defaults/main.yml index fc2ec30..68460c1 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,8 +1,9 @@ --- -pyenv_version: v2.3.3 +pyenv_version: v2.3.35 python39_version: 3.9.13 python38_version: 3.8.13 -python310_version: 3.10.6 +python310_version: 3.10.13 +python311_version: 3.11.7 python_versions: - '{{ python39_version }}' diff --git a/meta/main.yml b/meta/main.yml index 69cb29d..dc8de47 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -17,12 +17,12 @@ galaxy_info: versions: - 7 - 8 - - 9 - name: Ubuntu versions: - bionic - focal + - jammy galaxy_tags: - pyenv diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 2ffb257..e054301 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -3,9 +3,6 @@ dependency: name: galaxy driver: name: docker -lint: | - yamllint . - ansible-lint tasks/*.yml platforms: - name: centos7 image: centos:7 @@ -15,12 +12,13 @@ platforms: image: ubuntu:18.04 - name: ubuntu2004 image: ubuntu:20.04 + - name: ubuntu2204 + image: ubuntu:22.04 provisioner: name: ansible scenario: name: default test_sequence: - - lint - destroy - dependency - syntax diff --git a/molecule/default/prepare.yml b/molecule/default/prepare.yml index 5ee898a..4dc8088 100644 --- a/molecule/default/prepare.yml +++ b/molecule/default/prepare.yml @@ -3,29 +3,29 @@ hosts: all gather_facts: true tasks: - - rpm_key: + - ansible.builtin.rpm_key: state: present key: https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-8 when: ansible_os_family == 'RedHat' become: true - name: Install Fedora EPEL repo - yum: + ansible.builtin.yum: name: https://dl.fedoraproject.org/pub/epel/epel-release-latest-{{ ansible_distribution_major_version }}.noarch.rpm state: present when: ansible_os_family == 'RedHat' become: true - name: Update APT cache - apt: + ansible.builtin.package: update_cache: yes when: ansible_distribution == 'Ubuntu' become: true - name: Install Git - package: name=git state=present + ansible.builtin.package: name=git state=present - name: Install Python compile dependencies - yum: + ansible.builtin.yum: name: - bzip2-devel - gcc @@ -36,7 +36,7 @@ become: true - name: Install Python compile dependencies - apt: + ansible.builtin.package: name: - libbz2-dev - gcc diff --git a/tasks/main.yml b/tasks/main.yml index 6b936d3..5db66c9 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,13 +1,13 @@ --- - name: Include distro specific variables - include_vars: "{{ item }}" + ansible.builtin.include_vars: "{{ item }}" with_first_found: - '{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml' - '{{ ansible_distribution }}.yml' - '{{ ansible_os_family }}.yml' - name: Install Python - package: + ansible.builtin.package: name: '{{ python_packages }}' state: present become: true @@ -15,15 +15,15 @@ - name: Pre-set python versions required for pyenv global command block: - name: "Set Python version on Ubuntu >= 18.04 or CentOS 7" - set_fact: + ansible.builtin.set_fact: pyenv_cmd: "{{ python_versions | join(' ') }}" when: - (ansible_distribution == 'Ubuntu' and ansible_distribution_version >= '18.04') or (ansible_distribution == 'CentOS') - name: "Set Python 3.10 on CentOS >= 8 or on Ubuntu >= 18/04" - set_fact: - pyenv_cmd: "{{ (python_versions | join(' ')) ~ ' ' ~ python310_version }}" + ansible.builtin.set_fact: + pyenv_cmd: "{{ (python_versions | join(' ')) ~ ' ' ~ python310_version ~ ' ' ~ python311_version }}" when: - (ansible_distribution == 'Ubuntu' and ansible_distribution_version >= '18.04') or (ansible_distribution == 'CentOS' and ansible_distribution_major_version >= '8') @@ -33,37 +33,43 @@ # The compat-openssl libs are available only for CentOS8, so python 3.10x will # be available for >= CentOS8 - name: Install SSL dependencies required pyenv for python 3.10.x + become: true block: - - name: Update SSL dependencies for CentOS - command: "dnf install compat-openssl10* -y" + - name: Update SSL dependencies for CentOS # noqa no-changed-when + ansible.builtin.command: "dnf install compat-openssl10* -y" when: ansible_distribution == 'CentOS' and ansible_distribution_major_version >= '8' - become: true - name: Install Python 3.x versions via pyenv + become: true environment: PYENV_ROOT: /opt/pyenv PATH: '/opt/pyenv/bin:{{ ansible_env.PATH }}' PYTHON38_VERSION: '{{ python38_version }}' PYTHON39_VERSION: '{{ python39_version }}' PYTHON310_VERSION: '{{ python310_version }}' + PYTHON311_VERSION: '{{ python311_version }}' block: - name: 'Install pyenv {{ pyenv_version }}' - git: + ansible.builtin.git: repo: https://github.com/pyenv/pyenv.git dest: /opt/pyenv version: '{{ pyenv_version }}' - - name: 'Install Python {{ pyenv_cmd }}' - command: 'pyenv install -s {{ item }}' + - name: 'Install Python {{ pyenv_cmd }}' # noqa no-changed-when + ansible.builtin.command: 'pyenv install -s {{ item }}' loop: '{{ python_versions }}' - - name: 'Install Python {{ python310_version }}' - command: 'pyenv install -s {{ python310_version }}' + - name: 'Install Python {{ python310_version }}' # noqa no-changed-when + ansible.builtin.command: pyenv install -s {{ python310_version }} when: - (ansible_distribution == 'Ubuntu' and ansible_distribution_version >= '18.04') or (ansible_distribution == 'CentOS' and ansible_distribution_major_version >= '8') - - name: 'Set the required python 3.x versions using pyenv on Ubuntu' - command: 'pyenv global system {{ pyenv_cmd }}' + - name: 'Install Python {{ python311_version }}' # noqa no-changed-when + ansible.builtin.command: pyenv install -s {{ python311_version }} + when: + - (ansible_distribution == 'Ubuntu' and ansible_distribution_version >= '18.04') or + (ansible_distribution == 'CentOS' and ansible_distribution_major_version >= '8') + - name: 'Set the required python 3.x versions using pyenv on Ubuntu' # noqa no-changed-when + ansible.builtin.command: 'pyenv global system {{ pyenv_cmd }}' when: ansible_distribution == 'Ubuntu' - - name: 'Set the required python 3.x versions using pyenv on CentOS' - command: 'pyenv global {{ pyenv_cmd }}' + - name: 'Set the required python 3.x versions using pyenv on CentOS' # noqa no-changed-when + ansible.builtin.command: 'pyenv global {{ pyenv_cmd }}' when: ansible_distribution == 'CentOS' - become: true diff --git a/tox.ini b/tox.ini index 777d967..5ad109a 100644 --- a/tox.ini +++ b/tox.ini @@ -2,20 +2,17 @@ minversion = 1.6 envlist = molecule, - pre-commit + pre-commit, + lint skipsdist=true [testenv:molecule] basepython = python3 deps = - ansible~=2.9.6 - ansible-lint~=4.2.0 - detox~=0.18 + ansible docker - yamllint - molecule~=3.0.8 - molecule[docker] - pytest~=5.4.0 + molecule + molecule-docker passenv = * commands = ./molecule.sh @@ -23,8 +20,10 @@ allowlist_externals = ./molecule.sh [testenv:pre-commit] +allowlist_externals = + /bin/sh deps = pre-commit -allowlist_externals = /bin/sh +passenv = HOME commands = pre-commit run --all-files --show-diff-on-failure /bin/sh -c 'if ! git config --get user.name > /dev/null; then \ @@ -44,3 +43,15 @@ commands = /bin/sh -c "if [ -f .git/REMOVE_USEREMAIL ]; then \ git config --global --unset user.email; \ rm -f .git/REMOVE_USEREMAIL; fi" + +[testenv:lint] +basepython = python310 +deps = + ansible-lint + yamllint +commands = + /bin/bash -c "ansible-lint tasks/*.yml" + yamllint . +allowlist_externals = + /bin/bash + yamllint diff --git a/vars/Ubuntu-22.yml b/vars/Ubuntu-22.yml new file mode 100644 index 0000000..cb4d2b5 --- /dev/null +++ b/vars/Ubuntu-22.yml @@ -0,0 +1,13 @@ +--- +python_packages_distro: + - libffi-dev + - libssl-dev + - python-is-python3 + - python3 + - python3 + - python3-dev + - python3-openssl + - python3-pip + - python3-setuptools + - python3-virtualenv + - python3-venv