-
-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UnixPB: Add latest commit SHA to ansible.log file (#2751)
* add latest commit sha to logs * remove debug * remove duplicate code and change log path * add debug to see where ansible's working directory is * add ignore_errors * remove debug * copy one directory up in build workflow * typo * debugging * pass git sha into dockerfile * pass git sha from build.yml into dockerfile * remove debug code * use env instead of args * forgot to add env to centos6 build * remove brackets to see if this works * use different syntax for variable * remove - from env * add build-args to build.yml * add start logs * change hosts back to original value
- Loading branch information
1 parent
76d51f1
commit de2d533
Showing
6 changed files
with
43 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 23 additions & 19 deletions
42
ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/logs/tasks/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,45 @@ | ||
--- | ||
# Updates $HOME/ansible.log with the date and time of latest ansible playbook run | ||
|
||
- name: Set variables (Linux) | ||
- name: Set Log path | ||
set_fact: | ||
home_path: /home/{{ Jenkins_Username }} | ||
user_group: "{{ Jenkins_Username }}" | ||
when: | ||
- ansible_distribution != "MacOSX" | ||
- ansible_distribution != "Solaris" | ||
log_path: /var/log | ||
|
||
- name: Set variables (MacOS) | ||
set_fact: | ||
home_path: /Users/{{ Jenkins_Username }} | ||
user_group: "staff" | ||
when: | ||
- ansible_distribution == "MacOSX" | ||
|
||
- name: Set variables (Solaris) | ||
- name: Set variables (Not MacOS) | ||
set_fact: | ||
home_path: /export/home/{{ Jenkins_Username }} | ||
user_group: "{{ Jenkins_Username }}" | ||
user_group: "root" | ||
when: | ||
- ansible_distribution == "Solaris" | ||
- ansible_distribution != "MacOSX" | ||
|
||
- name: Check if Jenkins user exists | ||
stat: | ||
path: "{{ home_path }}" | ||
register: home_exists | ||
- name: Get Date and Time | ||
shell: date +%Y-%m-%d\ %H:%M:%S | ||
register: date_output | ||
|
||
- name: Get Latest git commit SHA | ||
shell: git rev-parse HEAD | ||
register: git_output | ||
delegate_to: localhost | ||
ignore_errors: yes | ||
when: git_sha is not defined | ||
|
||
- name: Set git_output to git_sha | ||
set_fact: | ||
git_sha: "{{ git_output.stdout }}" | ||
when: git_sha is not defined | ||
|
||
- name: Update Log File | ||
lineinfile: | ||
owner: "{{ Jenkins_Username }}" | ||
owner: root | ||
group: "{{ user_group }}" | ||
create: yes | ||
path: "{{ home_path }}/ansible.log" | ||
path: "{{ log_path }}/ansible.log" | ||
insertafter: EOF | ||
line: "{{ ansible_date_time.date }} -- {{ ansible_date_time.time }}" | ||
line: "{{ position }} {{ date_output.stdout }} {{ git_sha }}" | ||
become: yes | ||
become_user: root | ||
when: home_exists.stat.exists |