lvrfrc87 / lvrfrc87.git_acp / 2.2.0 / module / git_acp Perform git add, commit, pull and push operations. Authors: Federico Olivieri (@Federico87)lvrfrc87.git_acp.git_acp (2.2.0) — module
Install with ansible-galaxy collection install lvrfrc87.git_acp:==2.2.0
collections: - name: lvrfrc87.git_acp version: 2.2.0
Manage C(git add), C(git commit) C(git push) and C(git pull) on a git repository.
- name: ADD FILE-1 VIA HTTPS. environment: GIT_AUTHOR_NAME: "me" GIT_AUTHOR_EMAIL: "me@me.me" GIT_COMMITTER_NAME: "me" GIT_COMMITTER_EMAIL: "me@me.me" git_acp: path: "{{ working_dir }}" branch: "master" comment: "Add {{ file1 }}." add: [ "." ] url: "{{ https_repo }}"
- name: PUSH REMOVE FILE-1 VIA HTTPS + FORCE. environment: GIT_AUTHOR_NAME: "me" GIT_AUTHOR_EMAIL: "me@me.me" GIT_COMMITTER_NAME: "me" GIT_COMMITTER_EMAIL: "me@me.me" git_acp: path: "{{ working_dir }}" branch: "master" comment: "Remove {{ file1 }}." add: [ "." ] url: "{{ https_repo }}" push_force: true
- name: PULL BEFORE TO PUSH. environment: GIT_AUTHOR_NAME: "me" GIT_AUTHOR_EMAIL: "me@me.me" GIT_COMMITTER_NAME: "me" GIT_COMMITTER_EMAIL: "me@me.me" git_acp: comment: "Pull before to push." path: "{{ _pull_dest.path }}" url: "{{ _pull_src.path }}" pull: true
- name: ADD FILES ONLY. - NO PUSH environment: GIT_AUTHOR_NAME: "me" GIT_AUTHOR_EMAIL: "me@me.me" GIT_COMMITTER_NAME: "me" GIT_COMMITTER_EMAIL: "me@me.me" git_acp: add: - "{{ item }}" branch: "master" comment: "Add {{ item }}" path: "{{ working_dir }}" push: false url: "{{ https_repo }}" loop: - "{{ file2 }}" - "{{ file3 }}"
- name: 10220 - PUSH FILE-2, FILE-3 ALONG WITH FILE-4. environment: GIT_AUTHOR_NAME: "me" GIT_AUTHOR_EMAIL: "me@me.me" GIT_COMMITTER_NAME: "me" GIT_COMMITTER_EMAIL: "me@me.me" git_acp: branch: "master" path: "{{ working_dir }}" url: "{{ https_repo }}" comment: "Add {{ file4 }}"
- name: PUSH VIA SSH AND CCEPT_HOSTKEY WHEN SSH DOES NOT SUPPORT THE OPTION environment: GIT_AUTHOR_NAME: me GIT_AUTHOR_EMAIL: me@me.me GIT_COMMITTER_NAME: me GIT_COMMITTER_EMAIL: me@me.me git_acp: url: "{{ ssh_repo }}" path: "{{ working_dir }}" branch: "master" comment: "Remove {{ file2 }}" add: [ "{{ file2 }}" ] ssh_params: accept_hostkey: true key_file: '{{ github_ssh_private_key }}' ssh_opts: '-o UserKnownHostsFile={{ remote_tmp_dir }}/known_hosts'
add: default: - . description: - List of files under C(path) to be staged. Same as C(git add .). File globs not accepted, such as C(./*) or C(*). Required when using C(comment). elements: str type: list url: description: - Git repo URL. required: true type: str path: description: - Folder path where C(.git/) is located. required: true type: path pull: default: false description: - Perform a git pull before pushing. type: bool version_added: 2.0.0 version_added_collection: lvrfrc87.git_acp push: default: true description: - Perform a git push. type: bool clean: choices: - ignored - untracked - all description: - If C(ignored), clean ignored files and directories in the repository. - If C(untracked), clean untracked files and directories in the repository. - If C(all), clean both ignored and untracked. required: false type: str version_added: 2.2.0 version_added_collection: lvrfrc87.git_acp branch: default: main description: - Git branch where perform git push. type: str comment: description: - Git commit comment. Same as C(git commit -m). Required when using C(add). type: str executable: description: - Path to git executable to use. If not supplied, the normal mechanism for resolving binary paths will be used. type: path version_added: 1.4.0 version_added_collection: lvrfrc87.git_acp push_force: default: false description: - Git push force options. Same as C(git push --force). type: bool version_added: 2.1.0 version_added_collection: lvrfrc87.git_acp ssh_params: description: - Dictionary containing SSH parameters. suboptions: accept_hostkey: description: - If C(yes), ensure that "-o StrictHostKeyChecking=no" is present as an ssh option. type: bool key_file: description: - Specify an optional private key file path, on the target host, to use for the checkout. type: path ssh_opts: description: - Creates a wrapper script and exports the path as GIT_SSH which git then automatically uses to override ssh arguments. An example value could be "-o StrictHostKeyChecking=no" (although this particular option is better set via C(accept_hostkey)). type: str type: dict version_added: 1.4.0 version_added_collection: lvrfrc87.git_acp push_option: description: - Git push options. Same as C(git --push-option=option). type: str pull_options: default: - --no-edit description: - Options added to the pull command. See C(git pull --help) for available options. elements: str type: list version_added: 2.0.0 version_added_collection: lvrfrc87.git_acp
output: description: dic of git cli commands stdout returned: always sample: result: changed: true failed: false git_commit: changed: true error: '' output: '[master 4596d9d] Add 1682063905033586650.txt. 1 file changed, ...' git_push: changed: true error: '' output: 'remote: Resolving deltas: 0% (0/1) remote: Resolving ...' type: dict