Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Ansible v2.x callback plugin that generates human-readable result logging in the Ansible log file

Notifications You must be signed in to change notification settings

jinesh-choksi/ansible-human_log

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ansible-human_log

This Ansible v2.x callback plugin generates human-readable result logging in the Ansible log file.

Requirements

This callback has not been tested on any version of Ansible other than v2.0.1.0. It requires Ansible >=v2.x.

Dependencies

none.

Example Usage

Assuming the following folder structure is in place:

.
├── ansible.cfg
├── callback_plugins
│   └── human_log.py
└── test.yml

File: ansible.cfg

[defaults]
log_path = ./ansible.log
callback_plugins = ./callback_plugins/

File: test.yml

---
- hosts: all
  become: yes
  tasks:
  - name: Saying hi
    debug: msg="Hello world!"
  - name: Ensure apache is at the latest version
    yum: name=httpd state=latest
...

If you run ansible-playbook, as a user who has sudo rights, in the folder containing the ansible.cfg + test.yml files + callback_plugins sub folder, as follows:

ansible-playbook -i 'localhost,' -c local test.yml

You should see the following output on screen:

Screen output

...and should see the creation of an ansible.log file which contains the following content:

2016-04-08 12:24:45,192 p=1987 u=algomi-deploy |  PLAY ***************************************************************************
2016-04-08 12:24:45,206 p=1987 u=algomi-deploy |  TASK [setup] *******************************************************************
2016-04-08 12:24:45,600 p=1987 u=algomi-deploy |  ok: [localhost]
2016-04-08 12:24:45,604 p=1987 u=algomi-deploy |  TASK [Saying hi] ***************************************************************
2016-04-08 12:24:45,617 p=1987 u=algomi-deploy |  ok: [localhost] => {
    "msg": "Hello world!"
}
2016-04-08 12:24:45,618 p=1987 u=algomi-deploy |  msg:
Hello world!
2016-04-08 12:24:45,619 p=1987 u=algomi-deploy |  TASK [Ensure apache is at the latest version] **********************************
2016-04-08 12:24:48,805 p=1987 u=algomi-deploy |  changed: [localhost]
2016-04-08 12:24:48,805 p=1987 u=algomi-deploy |  results:
Loaded plugins: fastestmirror
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: repo.bigstepcloud.com
 * epel: vesta.informatik.rwth-aachen.de
 * extras: mirror.simwood.com
 * updates: centos.serverspace.co.uk
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.2.15-47.el6.centos.4 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package      Arch          Version                        Repository      Size
================================================================================
Installing:
 httpd        x86_64        2.2.15-47.el6.centos.4         updates        831 k

Transaction Summary
================================================================================
Install       1 Package(s)

Total download size: 831 k
Installed size: 2.9 M
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
^M  Installing : httpd-2.2.15-47.el6.centos.4.x86_64                          1/1
^M  Verifying  : httpd-2.2.15-47.el6.centos.4.x86_64                          1/1

Installed:
  httpd.x86_64 0:2.2.15-47.el6.centos.4

Complete!

2016-04-08 12:24:48,806 p=1987 u=algomi-deploy |  PLAY RECAP *********************************************************************
2016-04-08 12:24:48,806 p=1987 u=algomi-deploy |  localhost                  : ok=3    changed=1    unreachable=0    failed=0

About

Ansible v2.x callback plugin that generates human-readable result logging in the Ansible log file

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%