Role for ansible logging
This commit is contained in:
parent
af1045d788
commit
7da18102f4
11
ansible-log/files/info.sh
Normal file
11
ansible-log/files/info.sh
Normal file
|
@ -0,0 +1,11 @@
|
|||
#!/bin/sh
|
||||
|
||||
git config --get remote.origin.url
|
||||
git log --pretty="%h - %s" -3
|
||||
|
||||
ansible_cfg=$(ansible --version|grep "config file"|awk -F'=' '{print $2}'|xargs)
|
||||
roles_path=$(grep "roles_path" $ansible_cfg|awk -F'=' '{print $2}'|sed "s|~|$HOME|"|xargs)
|
||||
|
||||
echo ""
|
||||
git -C $roles_path config --get remote.origin.url
|
||||
git -C $roles_path log --pretty="%h - %s" -3
|
16
ansible-log/tasks/main.yml
Normal file
16
ansible-log/tasks/main.yml
Normal file
|
@ -0,0 +1,16 @@
|
|||
---
|
||||
- name: Template
|
||||
local_action: template src=ansible-info.j2 dest=/tmp/ansible-info.log
|
||||
changed_when: no
|
||||
become: no
|
||||
|
||||
- name: Get info on local environment
|
||||
local_action: script info.sh >> /tmp/ansible-info.log
|
||||
changed_when: no
|
||||
become: no
|
||||
|
||||
- name: Copy ansible-info on remote server
|
||||
copy:
|
||||
src: /tmp/ansible-info.log
|
||||
dest: /var/log/ansible-info.log
|
||||
changed_when: no
|
10
ansible-log/templates/ansible-info.j2
Normal file
10
ansible-log/templates/ansible-info.j2
Normal file
|
@ -0,0 +1,10 @@
|
|||
date: {{ ansible_date_time.iso8601 }}
|
||||
|
||||
inventory: {{ inventory_file }}
|
||||
playbook_dir: {{ playbook_dir}}
|
||||
|
||||
hosts:
|
||||
{{ ansible_play_hosts | to_nice_yaml }}
|
||||
roles:
|
||||
{{ role_names | to_nice_yaml }}
|
||||
|
Loading…
Reference in a new issue