Skip to content

Instantly share code, notes, and snippets.

@vladzloteanu
Created December 26, 2017 17:43
Show Gist options
  • Save vladzloteanu/7f5985d15aeb7f97d04c2555c338042d to your computer and use it in GitHub Desktop.
Save vladzloteanu/7f5985d15aeb7f97d04c2555c338042d to your computer and use it in GitHub Desktop.
add git details.yml
- name: Get hostname
shell: echo $HOSTNAME
register: local_hostname
delegate_to: localhost
- name: Get current user
shell: whoami
register: local_user
delegate_to: localhost
- name: Get git version
shell: "git log -n 1"
args:
chdir: "{{ base_tmp_dir }}projects/{{ project.name }}"
register: git_last_commit
delegate_to: localhost
- name: Get git hash
shell: "git rev-parse HEAD"
args:
chdir: "{{ base_tmp_dir }}projects/{{ project.name }}"
register: git_last_commit_hash
delegate_to: localhost
- name: Get git last commit message
shell: "git log -1 --pretty=%B"
args:
chdir: "{{ base_tmp_dir }}projects/{{ project.name }}"
register: git_last_commit_comment
delegate_to: localhost
- name: Add .DEPLOY_DETAILS
blockinfile:
dest: "{{ release_folder }}.DEPLOY_DETAILS"
create: yes
block: |
Local deploy from: {{ local_hostname.stdout }}
Local deploy user: {{ local_user.stdout }}
Timestamp: {{ ansible_date_time.iso8601_basic_short }}
Git log:
{{ git_last_commit.stdout }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment