|
1 | 1 | --- |
2 | 2 | # Updates $HOME/ansible.log with the date and time of latest ansible playbook run |
3 | 3 |
|
4 | | -- name: Are we later than C6 |
5 | | - shell: echo We are later than CentOS6 |
6 | | - when: ansible_distribution_major_version| int > 6 |
7 | | - |
8 | | -- name: Are we earlier than C10 |
9 | | - shell: echo We are later than CentOS10 |
10 | | - when: ansible_distribution_major_version| int < 10 |
11 | | - |
12 | | -- name: Are we between C6 and C10 |
13 | | - shell: echo We are between C6 and C10 |
14 | | - when: |
15 | | - - ansible_distribution_major_version| int > 6 |
16 | | - - ansible_distribution_major_version| int < 10 |
17 | | - |
18 | | -#- name: Break |
19 | | -# shell: /bin/false |
20 | | - |
21 | 4 | - name: Set Log path |
22 | 5 | set_fact: |
23 | | - log_path: /var/log |
| 6 | + log_path: /var/log |
24 | 7 |
|
25 | 8 | - name: Set variables (MacOS) |
26 | 9 | set_fact: |
27 | | - user_group: "staff" |
| 10 | + user_group: "staff" |
28 | 11 | when: |
29 | | - - ansible_distribution == "MacOSX" |
| 12 | + - ansible_distribution == "MacOSX" |
30 | 13 |
|
31 | 14 | - name: Set variables (Not MacOS) |
32 | 15 | set_fact: |
33 | | - user_group: "root" |
| 16 | + user_group: "root" |
34 | 17 | when: |
35 | | - - ansible_distribution != "MacOSX" |
| 18 | + - ansible_distribution != "MacOSX" |
36 | 19 |
|
37 | 20 | - name: Get Date and Time |
38 | 21 | shell: date +%Y-%m-%d\ %H:%M:%S |
|
47 | 30 |
|
48 | 31 | - name: Set git_output to git_sha |
49 | 32 | set_fact: |
50 | | - git_sha: "{{ git_output.stdout }}" |
| 33 | + git_sha: "{{ git_output.stdout }}" |
51 | 34 | when: git_sha is not defined |
52 | 35 |
|
53 | 36 | - name: Update Log File |
54 | 37 | lineinfile: |
55 | | - owner: root |
56 | | - group: "{{ user_group }}" |
57 | | - create: yes |
58 | | - path: "{{ log_path }}/ansible.log" |
59 | | - insertafter: EOF |
60 | | - line: "{{ position }} {{ date_output.stdout }} {{ git_sha }}" |
| 38 | + owner: root |
| 39 | + group: "{{ user_group }}" |
| 40 | + create: yes |
| 41 | + path: "{{ log_path }}/ansible.log" |
| 42 | + insertafter: EOF |
| 43 | + line: "{{ position }} {{ date_output.stdout }} {{ git_sha }}" |
61 | 44 | become: yes |
62 | 45 | become_user: root |
0 commit comments