community.general.ansible_galaxy_install (8.5.0) — 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:==8.5.0


Add to requirements.yml

  collections:
    - name: community.general
      version: 8.5.0

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 O(type).
    - 'Please notice that C(ansible-galaxy) will not install collections with O(type=both),
      when O(requirements_file) contains both roles and collections and O(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 V(community.docker:1.6.1) or the role V(ansistrano.deploy,3.8.0).

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

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

force:
    default: false
    description:
    - Force overwriting an existing role or collection.
    - Using O(force=true) is mandatory when downgrading.
    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:
    - This option has no longer any effect and will be removed in community.general 9.0.0.
    type: bool

requirements_file:
    description:
    - Path to a file containing a list of requirements to be installed.
    - It works for O(type) equals to V(collection) and V(role).
    - O(name) and O(requirements_file) are mutually exclusive.
    type: path

ack_min_ansiblecore211:
    default: false
    description:
    - This option has no longer any effect and will be removed in community.general 9.0.0.
    type: bool

Outputs

dest:
  description: The value of the O(dest) parameter.
  returned: always
  type: str
force:
  description: The value of the O(force) parameter.
  returned: always
  type: bool
installed_collections:
  contains:
    <path>:
      description: Collections and versions for that path
      type: dict
  description:
  - If O(requirements_file) is specified instead, returns dictionary with all the
    collections installed per path.
  - If O(name) is specified, returns that collection name and the version installed
    per path.
  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 O(requirements_file) is specified instead, returns dictionary with all the
    roles installed per path.
  - If O(name) is specified, returns that role name and the version installed per
    path.
  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 O(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 O(requirements_file) parameter.
  returned: always
  type: str
type:
  description: The value of the O(type) parameter.
  returned: always
  type: str