From 6cb243b7a3625dadc76674d44bf6c61cde8fe180 Mon Sep 17 00:00:00 2001 From: Michael Savin Date: Sat, 1 Jul 2023 20:59:08 +0300 Subject: [PATCH] upd: Global refactoring --- .ansible-lint | 25 ++++++++----- .github/settings.yml | 2 +- .github/workflows/galaxy.yml | 8 ++--- .github/workflows/molecule.yml | 6 ++-- .github/workflows/todo.yml | 3 +- .yamllint | 1 + Taskfile.yml | 64 ++++++++++++++++++++++++++++++++++ meta/main.yml | 22 ++++++------ requirements.txt | 16 ++++----- tasks/main.yml | 4 +-- 10 files changed, 110 insertions(+), 41 deletions(-) create mode 100644 Taskfile.yml diff --git a/.ansible-lint b/.ansible-lint index 9eee302..787aa94 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -1,13 +1,20 @@ +--- +profile: production + exclude_paths: - - ./molecule/ - - ./.github/ + - .github/ + - molecule/ + - venv/ + parseable: true -quiet: true +quiet: false + skip_list: - - '401' - - '204' - - '403' - - '702' - - '305' + - "401" + - "204" + - "403" + - "702" + - "305" + use_default_rules: true -verbosity: 1 +verbosity: 3 diff --git a/.github/settings.yml b/.github/settings.yml index fe2f127..89dea9e 100644 --- a/.github/settings.yml +++ b/.github/settings.yml @@ -1,5 +1,5 @@ --- repository: description: Prepare your system to be managed by Ansible. - homepage: https://savinmi.ru/ + homepage: https://s11l.me/ topics: bootstrap, python, sudo, ansible, molecule, playbook diff --git a/.github/workflows/galaxy.yml b/.github/workflows/galaxy.yml index b88ab9d..726983b 100644 --- a/.github/workflows/galaxy.yml +++ b/.github/workflows/galaxy.yml @@ -1,9 +1,9 @@ --- name: Release to Ansible Galaxy -on: +"on": release: - types: [created, edited, published, released] + types: [ created, edited, published, released ] jobs: release: @@ -13,12 +13,12 @@ jobs: - name: Check out the codebase. uses: actions/checkout@v2 with: - path: 'jtprogru.sample_role' + path: "jtprogru.sample_role" - name: Set up Python 3. uses: actions/setup-python@v2 with: - python-version: '3.x' + python-version: "3.x" - name: Install Ansible. run: pip3 install ansible diff --git a/.github/workflows/molecule.yml b/.github/workflows/molecule.yml index 79b7aaa..dff82d8 100644 --- a/.github/workflows/molecule.yml +++ b/.github/workflows/molecule.yml @@ -5,13 +5,13 @@ name: Ansible Molecule -on: +"on": push: tags-ignore: - - '*' + - "*" pull_request: schedule: - - cron: '3 2 2 * *' + - cron: "3 2 2 * *" jobs: lint: diff --git a/.github/workflows/todo.yml b/.github/workflows/todo.yml index dc02e31..9ddae2f 100644 --- a/.github/workflows/todo.yml +++ b/.github/workflows/todo.yml @@ -1,9 +1,10 @@ --- name: "TODO 2 Issue" -on: +"on": push: + jobs: build: runs-on: "ubuntu-20.04" diff --git a/.yamllint b/.yamllint index c63ea03..a1c4dd0 100644 --- a/.yamllint +++ b/.yamllint @@ -4,6 +4,7 @@ ignore: | .github/* molecule/* + venv/* extends: default diff --git a/Taskfile.yml b/Taskfile.yml new file mode 100644 index 0000000..675e9f5 --- /dev/null +++ b/Taskfile.yml @@ -0,0 +1,64 @@ +# yaml-language-server: $schema=https://taskfile.dev/schema.json +--- +version: "3" + +set: + - pipefail + +silent: true + +tasks: + default: + desc: Show help + silent: true + cmds: + - task --list --color + + venv: + desc: Create python3 virtual environment + preconditions: + - test -f $(which python3) + cmds: + - $(which python3) -m venv venv + - ./venv/bin/python -m pip install --upgrade pip + + install:pip: + desc: Install python requirements + deps: + - venv + preconditions: + - test -d ./venv + - test -f requirements.txt + cmds: + - ./venv/bin/pip install -r requirements.txt + + anslint: + desc: Run ansible-lint + deps: + - install:pip + preconditions: + - test -f ./venv/bin/ansible-lint + cmds: + - ./venv/bin/ansible-lint --force-color . + + ymllint: + desc: Run yamllint + deps: + - install:pip + preconditions: + - test -f ./venv/bin/yamllint + cmds: + - ./venv/bin/yamllint --format auto --strict . + + lint: + desc: Run all linters + cmds: + - task: ymllint + - task: anslint + + test: + desc: Run test for this role + deps: + - lint + cmds: + - echo "Oooops... Need to implement!" diff --git a/meta/main.yml b/meta/main.yml index 13e162b..3c720ec 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -3,11 +3,11 @@ galaxy_info: namespace: jtprogru author: Michael Savin description: This is sample ansible role used me as boilerplate - company: SysOps + company: Bear on server # If the issue tracker for your role is not on github, uncomment the # next line and provide a value - # issue_tracker_url: http://example.com/issue/tracker + issue_tracker_url: https://github.com/jtprogru/sample-role/issues # Choose a valid license ID from https://spdx.org - some suggested licenses: # - BSD-3-Clause (default) @@ -18,7 +18,7 @@ galaxy_info: # - CC-BY-4.0 license: WTFPL - min_ansible_version: 2.9 + min_ansible_version: "2.9" # If this a Container Enabled role, provide the minimum Ansible Container version. # min_ansible_container_version: @@ -41,19 +41,19 @@ galaxy_info: # - 7 # - 99.99 + # List tags for your role here, one per line. A tag is a keyword that describes + # and categorizes the role. Users find roles by searching for tags. Be sure to + # remove the '[]' above, if you add tags to this list. + # + # NOTE: A tag is limited to a single word comprised of alphanumeric characters. + # Maximum 20 tags per role. galaxy_tags: - sample - role - example - sample-role - example-role - # List tags for your role here, one per line. A tag is a keyword that describes - # and categorizes the role. Users find roles by searching for tags. Be sure to - # remove the '[]' above, if you add tags to this list. - # - # NOTE: A tag is limited to a single word comprised of alphanumeric characters. - # Maximum 20 tags per role. +# List your role dependencies here, one per line. Be sure to remove the '[]' above, +# if you add dependencies to this list. dependencies: [] - # List your role dependencies here, one per line. Be sure to remove the '[]' above, - # if you add dependencies to this list. diff --git a/requirements.txt b/requirements.txt index ba1d384..8344c67 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,10 +1,6 @@ -# These role have been tested with these PIP component. -# To install the required version yourself, use a command as: -# `python -m pip --user install -r requirements.txt` -# See the pip requirements file documentation for details: -# https://pip.pypa.io/en/stable/user_guide/#requirements-files -# -# Tests run on the previous and current (latest) version of Ansible. -ansible>=2.10 -# Some Jinja2 filters are used that are available in the newer releases. -jinja2>=2.11.2 +ansible==7.5.0 +ansible-core==2.14.5 +ansible-lint==6.17.2 +black==23.3.0 +jmespath==1.0.1 +yamllint==1.31.0 diff --git a/tasks/main.yml b/tasks/main.yml index d8e0670..c6ce786 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,4 +1,4 @@ --- # tasks file for sample-role -- name: sample_role | sample ping - ping: +- name: Sample ping + ansible.builtin.ping: