Create notification system for workstations to know when Ansible has been run.
This commit is contained in:
@@ -11,10 +11,13 @@
|
|||||||
git_repo_http: https://{{ git_host }}/{{ git_user }}/{{ git_project }}
|
git_repo_http: https://{{ git_host }}/{{ git_user }}/{{ git_project }}
|
||||||
git_repo_ssh: ssh://git@{{ git_host }}:{{ git_ssh_port }}/{{ git_user }}/{{ git_project }}
|
git_repo_ssh: ssh://git@{{ git_host }}:{{ git_ssh_port }}/{{ git_user }}/{{ git_project }}
|
||||||
shared_rc_install_dir: ~/.git-env-shared
|
shared_rc_install_dir: ~/.git-env-shared
|
||||||
|
notify_log: "ansible.notify.log"
|
||||||
|
|
||||||
- name: General | Facts | System | Global [2/2]
|
- name: General | Facts | System | Global [2/2]
|
||||||
set_fact:
|
set_fact:
|
||||||
shared_rc_bin: "{{ shared_rc_install_dir }}/bin-shared"
|
shared_rc_bin: "{{ shared_rc_install_dir }}/bin-shared"
|
||||||
|
notify_log_file: /var/log/{{ notify_log }}
|
||||||
|
notify_log_file_wip: /tmp/{{ notify_log }}.wip
|
||||||
|
|
||||||
- name: General | Facts | System | Linux
|
- name: General | Facts | System | Linux
|
||||||
set_fact:
|
set_fact:
|
||||||
|
|||||||
38
local.yml
38
local.yml
@@ -21,6 +21,19 @@
|
|||||||
- include_tasks: facts/general/user.yml
|
- include_tasks: facts/general/user.yml
|
||||||
|
|
||||||
|
|
||||||
|
####### Start #######
|
||||||
|
|
||||||
|
- name: Main | Start
|
||||||
|
block:
|
||||||
|
|
||||||
|
- name: Main | Start | Notify | Touch File
|
||||||
|
include_tasks: tasks/general/acct_mgmt/notify.yml
|
||||||
|
|
||||||
|
- name: Main | Start | Notify | Add Message
|
||||||
|
shell : echo "'Ansible' 'Provisioning started @ `date`'" >> "{{ notify_log_file }}"
|
||||||
|
|
||||||
|
when: workstation == true
|
||||||
|
|
||||||
####### NixOS #######
|
####### NixOS #######
|
||||||
# Install the .nix files and do a little data setup.
|
# Install the .nix files and do a little data setup.
|
||||||
|
|
||||||
@@ -246,8 +259,25 @@
|
|||||||
####### Reporting #######
|
####### Reporting #######
|
||||||
# Provide information for analysis.
|
# Provide information for analysis.
|
||||||
|
|
||||||
- include_tasks: tasks/general/software/telegraf.yml
|
- name: Main | Reporting
|
||||||
|
block:
|
||||||
|
|
||||||
- include_tasks: tasks/general/tests/services.yml
|
- include_tasks: tasks/general/software/telegraf.yml
|
||||||
- include_tasks: tasks/general/tests/lynis.yml
|
|
||||||
- include_tasks: tasks/general/tests/nmap.yml
|
- include_tasks: tasks/general/tests/services.yml
|
||||||
|
- include_tasks: tasks/general/tests/lynis.yml
|
||||||
|
- include_tasks: tasks/general/tests/nmap.yml
|
||||||
|
|
||||||
|
|
||||||
|
####### Finish #######
|
||||||
|
|
||||||
|
- name: Main | Finish
|
||||||
|
block:
|
||||||
|
|
||||||
|
- name: Main | Finish | Notify | Touch File
|
||||||
|
include_tasks: tasks/general/acct_mgmt/notify.yml
|
||||||
|
|
||||||
|
- name: Main | Finish | Notify | Add Message
|
||||||
|
shell : echo "'Ansible' 'Provisioning finished @ `date`'" >> "{{ notify_log_file }}"
|
||||||
|
|
||||||
|
when: workstation == true
|
||||||
|
|||||||
8
tasks/general/acct_mgmt/notify.yml
Normal file
8
tasks/general/acct_mgmt/notify.yml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
# Create and manage permissions for notify log.
|
||||||
|
|
||||||
|
- name: General | Notify | Update File
|
||||||
|
shell: "{{ item }}"
|
||||||
|
loop:
|
||||||
|
- touch "{{ notify_log_file }}"
|
||||||
|
- chmod 777 "{{ notify_log_file }}"
|
||||||
@@ -1099,6 +1099,15 @@
|
|||||||
if [ -f ~/.rc_shared ]; then
|
if [ -f ~/.rc_shared ]; then
|
||||||
source ~/.rc_shared
|
source ~/.rc_shared
|
||||||
fi
|
fi
|
||||||
|
process_notify_log: |
|
||||||
|
if [[ -e {{ notify_log_file }} ]]; then
|
||||||
|
cp "{{ notify_log_file }}" "{{ notify_log_file_wip }}" 1>/dev/null
|
||||||
|
echo -n "" > "{{ notify_log_file }}"
|
||||||
|
cat "{{ notify_log_file_wip }}" | while read title message; do
|
||||||
|
notify-send "$title" "$message"
|
||||||
|
done
|
||||||
|
sh -c "rm '{{ notify_log_file_wip }}'"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
- name: General | Account Management | Users | Files | Common Variable
|
- name: General | Account Management | Users | Files | Common Variable
|
||||||
@@ -1181,6 +1190,7 @@
|
|||||||
{{ alias_flatpak_clean }}
|
{{ alias_flatpak_clean }}
|
||||||
{{ alias_commit }}
|
{{ alias_commit }}
|
||||||
{{ function_loop }}
|
{{ function_loop }}
|
||||||
|
{{ process_notify_log }}
|
||||||
|
|
||||||
- name: General | Account Management | Users | Files | .bashrc
|
- name: General | Account Management | Users | Files | .bashrc
|
||||||
blockinfile:
|
blockinfile:
|
||||||
|
|||||||
@@ -247,7 +247,7 @@
|
|||||||
true && inc_dconf &&
|
true && inc_dconf &&
|
||||||
|
|
||||||
dconf write /org/gnome/desktop/notifications/show-banners \
|
dconf write /org/gnome/desktop/notifications/show-banners \
|
||||||
false && inc_dconf &&
|
true && inc_dconf &&
|
||||||
dconf write /org/gnome/desktop/notifications/application/org-gnome-evolution-alarm-notify/enable-sound-alerts \
|
dconf write /org/gnome/desktop/notifications/application/org-gnome-evolution-alarm-notify/enable-sound-alerts \
|
||||||
false && inc_dconf &&
|
false && inc_dconf &&
|
||||||
dconf write /org/gnome/desktop/notifications/application/org-gnome-evolution-alarm-notify/enable \
|
dconf write /org/gnome/desktop/notifications/application/org-gnome-evolution-alarm-notify/enable \
|
||||||
|
|||||||
Reference in New Issue
Block a user