techbeck03.git_controls.git_clone (1.0.7) — module

Add or remove a local git repo clone

| "added in version" 1.0.0 of techbeck03.git_controls"

Authors: Brandon Beck (@techBeck03)

Install collection

Install with ansible-galaxy collection install techbeck03.git_controls:==1.0.7


Add to requirements.yml

  collections:
    - name: techbeck03.git_controls
      version: 1.0.7

Description

This module adds or removes a git repo clone to the specified working directory

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Clone git repo to auto-generated folder
-   name: Clone git repo to auto-generated folder
    techbeck03.git_controls.git_clone.git_clone:
        repo: "myrepo"
        org: "username"
        branch: "master"
        auto_generate_parent: True
        working_dir: /tmp
        state: present
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Clone a repo
-   name: Clone git repo to existing folder and pull latest changes
    techbeck03.git_controls.git_clone.git_clone:
        repo: "myrepo"
        org: "username"
        branch: "master"
        pull: True
        working_dir: /tmp/myrepo
        state: present

Inputs

    
org:
    description:
    - Name of the GitHub organization (or user account)
    - If not set, the value of the C(GIT_ORG) environment variable is used.
    required: true
    type: str

pull:
    default: false
    description:
    - If C(True) a git pull is executed if I(working_dir) contains an existing git repo
    required: false
    type: str

repo:
    description:
    - Name of the GitHub repository
    - If not set, the value of the C(GIT_REPO) environment variable is used.
    required: true
    type: str

state:
    choices:
    - present
    - absent
    default: present
    description:
    - If I(state=present) the specified repo will be cloned to the working directory
    - If I(state=absent) the specified working directory will be removed
    required: false
    type: str

branch:
    default: master
    description:
    - Name of the GitHub repository branch
    required: true
    type: str

git_token:
    description:
    - Git token used for authentication
    - Required if I(git_username=None)
    - If not set, the value of the C(GIT_TOKEN) environment variable is used.
    required: false
    type: str

working_dir:
    description: Path to the working directory for git clone
    required: true
    type: str

git_password:
    description:
    - Password used for Github authorization
    - Required if I(git_token=None)
    - If not set, the value of the C(GIT_PASSWORD) environment variable is used.
    required: false
    type: str

git_username:
    description:
    - Username used for Github authorization
    - Required if I(git_token=None)
    - If not set, the value of the C(GIT_USERNAME) environment variable is used.
    required: false
    type: str

auto_generate_parent:
    default: false
    description:
    - If C(True) a unique folder will be created in the provided working directory
    - to house the cloned repo
    required: false
    type: str

Outputs

working_dir:
  description: The path to working directory for the cloned git repo
  returned: always
  sample: /tmp/myrepo
  type: str