community.general.ansible_galaxy_install (6.6.8) — module

Install Ansible roles or collections using ansible-galaxy

| "added in version" 3.5.0 of community.general"

Authors: Alexei Znamensky (@russoz)

Install collection

Install with ansible-galaxy collection install community.general:==6.6.8


Add to requirements.yml

  collections:
    - name: community.general
      version: 6.6.8

Description

This module allows the installation of Ansible collections or roles using C(ansible-galaxy).


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Install collection community.network
  community.general.ansible_galaxy_install:
    type: collection
    name: community.network
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Install role at specific path
  community.general.ansible_galaxy_install:
    type: role
    name: ansistrano.deploy
    dest: /ansible/roles
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Install collections and roles together
  community.general.ansible_galaxy_install:
    type: both
    requirements_file: requirements.yml
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Force-install collection community.network at specific version
  community.general.ansible_galaxy_install:
    type: collection
    name: community.network:3.0.2
    force: true

Inputs

    
dest:
    description:
    - The path to the directory containing your collections or roles, according to the
      value of I(type).
    - 'Please notice that C(ansible-galaxy) will not install collections with I(type=both),
      when I(requirements_file) contains both roles and collections and I(dest) is specified.

      '
    type: path

name:
    description:
    - Name of the collection or role being installed.
    - 'Versions can be specified with C(ansible-galaxy) usual formats. For example, the
      collection C(community.docker:1.6.1) or the role C(ansistrano.deploy,3.8.0).

      '
    - I(name) and I(requirements_file) are mutually exclusive.
    type: str

type:
    choices:
    - collection
    - role
    - both
    description:
    - The type of installation performed by C(ansible-galaxy).
    - If I(type) is C(both), then I(requirements_file) must be passed and it may contain
      both roles and collections.
    - 'Note however that the opposite is not true: if using a I(requirements_file), then
      I(type) can be any of the three choices.'
    - 'B(Ansible 2.9): The option C(both) will have the same effect as C(role).'
    required: true
    type: str

force:
    default: false
    description:
    - Force overwriting an existing role or collection.
    - Using I(force=true) is mandatory when downgrading.
    - 'B(Ansible 2.9 and 2.10): Must be C(true) to upgrade roles and collections.'
    type: bool

no_deps:
    default: false
    description:
    - Refrain from installing dependencies.
    type: bool
    version_added: 4.5.0
    version_added_collection: community.general

ack_ansible29:
    default: false
    description:
    - Acknowledge using Ansible 2.9 with its limitations, and prevents the module from
      generating warnings about them.
    - This option is completely ignored if using a version of Ansible greater than C(2.9.x).
    - Note that this option will be removed without any further deprecation warning once
      support for Ansible 2.9 is removed from this module.
    type: bool

requirements_file:
    description:
    - Path to a file containing a list of requirements to be installed.
    - It works for I(type) equals to C(collection) and C(role).
    - I(name) and I(requirements_file) are mutually exclusive.
    - 'B(Ansible 2.9): It can only be used to install either I(type=role) or I(type=collection),
      but not both at the same run.'
    type: path

ack_min_ansiblecore211:
    default: false
    description:
    - Acknowledge the module is deprecating support for Ansible 2.9 and ansible-base 2.10.
    - Support for those versions will be removed in community.general 8.0.0. At the same
      time, this option will be removed without any deprecation warning!
    - This option is completely ignored if using a version of ansible-core/ansible-base/Ansible
      greater than C(2.11).
    - For the sake of conciseness, setting this parameter to C(true) implies I(ack_ansible29=true).
    type: bool

Outputs

dest:
  description: The value of the I(dest) parameter.
  returned: always
  type: str
force:
  description: The value of the I(force) parameter.
  returned: always
  type: bool
installed_collections:
  contains:
    <path>:
      description: Collections and versions for that path
      type: dict
  description:
  - If I(requirements_file) is specified instead, returns dictionary with all the
    collections installed per path.
  - If I(name) is specified, returns that collection name and the version installed
    per path.
  - 'B(Ansible 2.9): Returns empty because C(ansible-galaxy) has no C(list) subcommand.'
  returned: always when installing collections
  sample:
    /custom/ansible/ansible_collections:
      community.general: 3.1.0
    /home/az/.ansible/collections/ansible_collections:
      community.docker: 1.6.0
      community.general: 3.0.2
  type: dict
installed_roles:
  contains:
    <path>:
      description: Roles and versions for that path.
      type: dict
  description:
  - If I(requirements_file) is specified instead, returns dictionary with all the
    roles installed per path.
  - If I(name) is specified, returns that role name and the version installed per
    path.
  - 'B(Ansible 2.9): Returns empty because C(ansible-galaxy) has no C(list) subcommand.'
  returned: always when installing roles
  sample:
    /custom/ansible/roles:
      ansistrano.deploy: 3.8.0
    /home/user42/.ansible/roles:
      ansistrano.deploy: 3.9.0
      baztian.xfce: v0.0.3
  type: dict
name:
  description: The value of the I(name) parameter.
  returned: always
  type: str
new_collections:
  description: New collections installed by this module.
  returned: success
  sample:
    community.docker: 1.6.1
    community.general: 3.1.0
  type: dict
new_roles:
  description: New roles installed by this module.
  returned: success
  sample:
    ansistrano.deploy: 3.8.0
    baztian.xfce: v0.0.3
  type: dict
requirements_file:
  description: The value of the I(requirements_file) parameter.
  returned: always
  type: str
type:
  description: The value of the I(type) parameter.
  returned: always
  type: str