ansible / ansible-lint-action

❗️Replaced by https://github.com/marketplace/actions/run-ansible-lint
https://github.com/marketplace/actions/run-ansible-lint
MIT License
254 stars 132 forks source link

Ansible lint not been able to use community.general.system.timezone #155

Closed svenikea closed 1 year ago

svenikea commented 1 year ago

Hi ansible team,

I encounter this problem when running ansible lint on my playbook

Error: couldn't resolve module/action 'community.general.system.timezone'. This often indicates a misspelling, missing collection, or incorrect module path.
You can skip specific rules or tags by adding them to your configuration file:
# .config/ansible-lint.yml
warn_list:  # or 'skip_list' to silence them completely
  - syntax-check[specific]  # Ansible syntax check failed.

                  Rule Violation Summary                   
 count tag                    profile rule associated tags 
     1 syntax-check[specific] min     core                 

Failed after : 1 failure(s), 0 warning(s) on 1 files.
A new release of ansible-lint is available: 6.11.0 → 6.12.0

Apparently, it didn't detect the timezone community module when running the playbook, is there a workaround for this?

Please let me know, many thanks

ssbarnea commented 1 year ago

You need to add community.general into your requirements.yml or it will not be installed.

svenikea commented 1 year ago

Hi @ssbarnea, thank you for your response, I had put community.general into requirements.yml in my Ansible root project but the problem still persists, I even install ansible and install community.general with galaxy like below

on: 
  pull_request:
    paths:
      - ansible/**
jobs:
  ansible-lint:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout base branch
        uses: actions/checkout@v3
        with:
          ref: '${{ github.event.pull_request.base.ref }}'

      - name: Install Ansible
        run: sudo apt install ansible -y

      - name: Install Ansible-Galaxy Requirements
        run: ansible-galaxy collection install community.general

      - name: Run ansible-lint on bastion playbook
        uses: ansible-community/ansible-lint-action@v6.11.0
        with:
          path: "ansible/setup-bastion.yml"

      - name: Run ansible-lint on app playbook
        uses: ansible-community/ansible-lint-action@v6.11.0
        with:
          path: "ansible/setup-app.yml"

Here is the output error from the ansible-lint step

WARNING  Overriding detected file kind 'yaml' with 'playbook' for given positional argument: ansible/setup-bastion.yml
WARNING  Listing 1 violation(s) that are fatal
syntax-check[specific]: couldn't resolve module/action 'community.general.timezone'. This often indicates a misspelling, missing collection, or incorrect module path.
ansible/roles/base/tasks/main.yml:38:3

Error: couldn't resolve module/action 'community.general.timezone'. This often indicates a misspelling, missing collection, or incorrect module path.
You can skip specific rules or tags by adding them to your configuration file:
# .config/ansible-lint.yml
warn_list:  # or 'skip_list' to silence them completely
  - syntax-check[specific]  # Ansible syntax check failed.

                  Rule Violation Summary                   
 count tag                    profile rule associated tags 
     1 syntax-check[specific] min     core                 

Failed after : 1 failure(s), 0 warning(s) on 1 files.

I hope you could help me more with this issue because I really like this action a lot!

svenikea commented 1 year ago

Since I can't fix this problem no matter what, I've decided to put .config/ansible-lint.yml and put a tag on community.general.timezone to make ansible lint skip this task but I can't make it happen. Ansible lint refuses to read my configuration, I tried to put it in my root repo and even put it in the ansible folder but it won't budge.

Here is my repo tree

.
├── ansible
│   └── .config
│       └── ansible-lint.yml
├── .config
│   └── ansible-lint.yml
└── .github
    └── workflows
        ├── ansible_ci.yml
        └── infracost.yml
t2d commented 1 year ago

@svenikea For me it worked like @ssbarnea explained. Check https://github.com/systemli/ansible-role-bind9/pull/64/commits/4908eabe43f828524355d6b950f57a7a19e4480c for an example

jamesholland-uk commented 1 year ago

I'm having the same issue as the original post, and only recently, it was previously working. Per this comment, I changed from ansible/ansible-lint-action@v6 to pinning the specific version ansible/ansible-lint-action@6.11.0 in my GitHub Action, and now it works again.