|
|
|
@ -3,6 +3,20 @@
|
|
|
|
|
- name: Configure your machine
|
|
|
|
|
hosts: all
|
|
|
|
|
|
|
|
|
|
pre_tasks:
|
|
|
|
|
- name: Write a start message to the playbook log
|
|
|
|
|
ansible.builtin.shell: >
|
|
|
|
|
printf "\nStarted playbook '{{ ansible_play_name }}' execution at {{ now() }}\n"
|
|
|
|
|
>> ./log/{{ inventory_hostname }}.log
|
|
|
|
|
run_once: true
|
|
|
|
|
delegate_to: localhost
|
|
|
|
|
args:
|
|
|
|
|
chdir: "{{ playbook_dir }}"
|
|
|
|
|
become: true
|
|
|
|
|
become_user: "{{ local_user }}"
|
|
|
|
|
changed_when: true
|
|
|
|
|
tags: always
|
|
|
|
|
|
|
|
|
|
roles:
|
|
|
|
|
- { role: common, become: true, tags: [ common ] }
|
|
|
|
|
- { role: common-systools, become: true, tags: [ common ] }
|
|
|
|
@ -27,15 +41,27 @@
|
|
|
|
|
# - { role: qbittorrent, become: true, tags: [ qbittorrent ] }
|
|
|
|
|
|
|
|
|
|
post_tasks:
|
|
|
|
|
# record the state (commit tag) of this playbook at time of last run
|
|
|
|
|
- name: Record the current commit tag of this playbook to log
|
|
|
|
|
- name: Log the current commit of '{{ ansible_play_name }}' playbook
|
|
|
|
|
local_action: >
|
|
|
|
|
shell git log --pretty="Playbook was last committed by %cn on %cd (%H)" -1
|
|
|
|
|
>> ./ansible.log
|
|
|
|
|
shell git log
|
|
|
|
|
--pretty="Playbook '{{ playbook_dir | basename }}' last commit %h %ci by %cn" -1
|
|
|
|
|
>> ./log/{{ inventory_hostname }}.log
|
|
|
|
|
args:
|
|
|
|
|
chdir: "{{ playbook_dir }}"
|
|
|
|
|
become: true
|
|
|
|
|
become_user: "{{ local_user }}"
|
|
|
|
|
tags: always
|
|
|
|
|
- name: Write an end message to the playbook log
|
|
|
|
|
ansible.builtin.shell: >
|
|
|
|
|
echo "Ended playbook '{{ ansible_play_name }}' execution at {{ now() }}"
|
|
|
|
|
>> ./log/{{ inventory_hostname }}.log
|
|
|
|
|
run_once: true
|
|
|
|
|
delegate_to: localhost
|
|
|
|
|
args:
|
|
|
|
|
chdir: "{{ playbook_dir }}"
|
|
|
|
|
become: true
|
|
|
|
|
become_user: "{{ local_user }}"
|
|
|
|
|
changed_when: true
|
|
|
|
|
tags: always
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|