Coder Social home page Coder Social logo

Comments (19)

hemberger avatar hemberger commented on May 20, 2024 1

I'm seeing this issue with ansible-lint 6.10.0 even after adding the community.general collection to my requirements.yml file.

WARNING  Unable to load module community.general.timezone at roles/system_config/tasks/main.yml:46 for options validation
WARNING  Unable to resolve FQCN for module community.general.timezone

Here's an example job:

https://github.com/smrealms/seed-server/actions/runs/3783650542/jobs/6432363437

And here's what my requirements.yml looks like:

---
collections:

  - community.general

roles:

  - src: geerlingguy.docker
    version: 5.2.1

  - src: hifis.unattended_upgrades
    version: v1.12.2

Am I doing something wrong here? Thanks!

from ansible-lint-action.

ssbarnea avatar ssbarnea commented on May 20, 2024

See https://docs.ansible.com/ansible/latest/galaxy/user_guide.html#install-multiple-collections-with-a-requirements-file

from ansible-lint-action.

cidrblock avatar cidrblock commented on May 20, 2024

I was able to get this working: (this doesn't cover the action part)

$ ansible-galaxy collection install community.general
---
- name: timezone
  hosts: all
  gather_facts: true
  vars:
    tz: Asia/Tokyo

  tasks:
    - name: "Set the timezone. {{ tz }}"
      community.general.timezone:
        name: "{{ tz }}"
      failed_when: false

from ansible-lint-action.

officel avatar officel commented on May 20, 2024

@ssbarnea @cidrblock thank you! I could complete.

my repo(ommit)

$ tree
.
|-- ansible
|   |-- .ansible-lint
|   |-- requirements.yml
|   `-- roles

my wf

    steps:
      - uses: actions/checkout@master

      - name: copy .ansible-lint
        shell: bash
        run: |
          cp ansible/.ansible-lint .
          cp ansible/requirements.yml .

      - name: Lint Ansible Playbook
        uses: ansible/ansible-lint-action@v6
        # uses: ./.github/actions/ansible-lint
        with:
          args: ansible

from ansible-lint-action.

officel avatar officel commented on May 20, 2024

wooops

$ cat ansible/requirements.yml
---
collections:
  - community.general

$ cat ansible/.ansible-lint
# see https://ansible-lint.readthedocs.io/en/latest/configuring/

# List of additional kind:pattern to be added at the top of the default
# match list, first match determines the file kind.
kinds:
  - playbook: "**/playbook*/*.{yml,yaml}"
  # - galaxy: "**/folder/galaxy.yml"
  # - tasks: "**/tasks/*.yml"
  # - vars: "**/vars/*.yml"
  # - meta: "**/meta/main.yml"
  - yaml: "**/*.yaml-too"

from ansible-lint-action.

officel avatar officel commented on May 20, 2024

@hemberger

see https://docs.ansible.com/ansible/latest/galaxy/user_guide.html

Installing both roles and collections from the same requirements file will not work when specifying a custom collection or role install path. In this scenario the collections will be skipped and the command will process each like ansible-galaxy role install would.

and old version
https://docs.ansible.com/ansible/2.9/galaxy/user_guide.html

While both roles and collections can be specified in one requirements file, they need to be installed separately. The ansible-galaxy role install -r requirements.yml will only install roles and ansible-galaxy collection install -r requirements.yml -p ./ will only install collections.

youe PR
https://github.com/smrealms/seed-server/pull/16/files#diff-5c9ed18af9a5f902219d12c3044ccb193c2c304a3748d02702889c2ca5703978R23

I think, maybe not installed colections.
need command like a ansible-galaxy collections install -r requirements.yml right?

from ansible-lint-action.

hemberger avatar hemberger commented on May 20, 2024

@officel Thanks for the pointers! I should have clarified that this is only an issue in the GitHub Action (locally, where I do have community.general installed, everything is working fine). I'm not sure what ansible-lint is doing under the hood to discover community collections. Do I need to run ansible-galaxy collections install -r requirements.yml in the GHA workflow before I run ansible-lint?

from ansible-lint-action.

officel avatar officel commented on May 20, 2024

I see. Then it does not seem necessary.

from ansible-lint-action.

officel avatar officel commented on May 20, 2024

@hemberger

I checked again.
I misunderstood because I am not good at English. Sorry 🙇

ansible-lint-action uses creator-ee with docker.
https://github.com/ansible/ansible-lint-action/blob/main/action.yml

creator-ee automatically reads requirements.yml in the top directory of the repository.
The requirements.yml it is based on does not contain the community.general collection we need.
https://github.com/ansible/creator-ee/blob/main/_build/requirements.yml

So when we use this ansible-lint-action, we need to put the collections in our requirements.yml.

No problem.

from ansible-lint-action.

Schachte avatar Schachte commented on May 20, 2024

@hemberger Did you get this working? I've modified my action to install the requirements from the root like so:

name: Ansible Deployment

on:
  workflow_dispatch:

jobs:
  linting:
    name: List Ansible Files
    runs-on: ubuntu-22.04

    steps:
    - name: Checkout Sources
      uses: actions/checkout@v2

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

    - name: Install Ansible-Galaxy Requirements
      run: ansible-galaxy install -r requirements.yaml

    - name: List Installed Ansible-Galaxy Requirements
      run: ansible-galaxy collection list

    - name: Linting
      uses: ansible/ansible-lint-action@dd225474d15635904348151b9e694472ce0f62a8
      with:
        path: ansible/

But I'm still getting FQCN resolution failures.

Collections

---
collections:
  - name: community.general
  - name: community.docker

from ansible-lint-action.

hemberger avatar hemberger commented on May 20, 2024

Did you get this working?

No, I haven't been able to get this to work either. Since ansible-lint is running in a docker container, my suspicion is that it will require changes to the creator-ee image or ansible-lint itself.

runs:
using: docker
image: docker://ghcr.io/ansible/creator-ee:v0.12.0
entrypoint: /usr/local/bin/ansible-lint

from ansible-lint-action.

Schachte avatar Schachte commented on May 20, 2024

Bummer. @ssbarnea Any ideas on this one?

from ansible-lint-action.

ssbarnea avatar ssbarnea commented on May 20, 2024

You must have a requirements.yml file on your repo so linter could install these deps itself! Running galaxy before the action does not help as that is not inside the action container.

from ansible-lint-action.

hemberger avatar hemberger commented on May 20, 2024

You must have a requirements.yml file on your repo so linter could install these deps itself! Running galaxy before the action does not help as that is not inside the action container.

Thanks for the quick response! In my example job above (#99 (comment)), I have community.general in my repo's requirements.yml file, but I still get the FQCN warning about it.

from ansible-lint-action.

Schachte avatar Schachte commented on May 20, 2024

Fair point. Can we override the path to avoid pushing the galaxy file into root?

from ansible-lint-action.

ssbarnea avatar ssbarnea commented on May 20, 2024

@Schachte You can pass path variable but that is not alone enough. You also need to create a config file at the desired location in order to convince linter to consider that path as project directory. Otherwise it will fallback to git and that will report the parent patch as being the project.

from ansible-lint-action.

nielsk avatar nielsk commented on May 20, 2024

Was there ever a solution to this? I have a chicken-egg-problem: when I put community.general into the requirements.yml I get an error that
ERROR! Failed to find the collection dir deps: The collection galaxy.yml path '/Users/nik/.cache/ansible-compat/bec60e/collections/ansible_collections/community/general/galaxy.yml' does not exist.

If I do not have community.general in the requirements.yml I get errors with playbooks that use modules from community.general that the dependencies are not in the requirements.yml.

from ansible-lint-action.

barzog avatar barzog commented on May 20, 2024

I've solved it by reverting to https://github.com/ansible/[email protected] from current @main - which uses 6.14.4.

from ansible-lint-action.

hervedevos avatar hervedevos commented on May 20, 2024

Same issue here, when i move back to v6.11.0 as suggested by @barzog it solves the issue but now my linter is buggy because of a loop-var-prefix[wrong] false positive, that seems to be fixed in a newer version of the linter...

from ansible-lint-action.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.