<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Ansible
Step1:  View of the network, private, from /etc/hosts
(/etc/hosts display truncated to avoid line wrap)
Step2:  Review of control machine's Ansible configuration
Let the Jupyter notebook know where to find files.
Step3:  Note use of group "aur" to provide value for "become" password.
Step4:  is the control machine able to reach the remote machines?
Ansilble module, ping, replies with the string "ping" the control machine successfully connects with the host in the group aur.
Step5:  Here Ansible runs a program on the remote machines.
connectivity is established
uptime for the remote machines may be of interest than the string "pong".
Step6:  Ansible's "setup" module; all it knows about a target machine
When Ansible's connects to a target machine it collects information as part of its setup.
The resulting data structure is collectively referred to as facts.
Step7:  Retrieve a subset of the facts.
From Loren Hochsetein's page
[https
Step8:  Report the target machines' date for rough idea of time synchrony.
From the control machine, Ansible concurrently accesses the target machines.
This example shows the three target machines are within a 100 milliseconds of each other.
Step9:  Results from piping commands on the remote machines.
Three commands on the target host to yield an IPv4 address of a network device.
(CentOS uses the “Predictable Network Interface Names” convention.)
Step10:  Ansible Playbooks
One playbook with one task and three debug statments concerning the network adapater Ansible is using by default."
Ansible's debug module is used to
*  print the IPv4 address
*  print the MAC address
*  print the IPv4 and MAC address togehter on one line
<ASSISTANT_TASK:>
Python Code:
import sys, platform, subprocess
ansibleVersion = subprocess.check_output(['ansible', '--version']).decode('utf-8').split()[1]
print(   f" Python:  {' '.join(sys.version.split()[0:4])}\n"  # Not the version of Pythone used by Ansible.
         f'  macOS:  {platform.mac_ver()[0]}\n'               # Control machine operatings sysrtem.
         f"Ansible:  {subprocess.check_output(['ansible', '--version']).decode('utf-8').split()[1]}")
Explanation: Ansible: Getting Started in a Jupyter Notebook
A Jupyter Notebook to follow along while reading "Ansible: Up and Running", 2nd Edition,
Lorin Hochstein, Rene Moser
http://shop.oreilly.com/product/0636920065500.do
Publisher: O'Reilly Media, Inc.  Release Date: August 2017  ISBN: 9781491979808
Remote machines of interest to the control machine:
<img src="w530_aur_components.png"</>
Ansible Control Machine: what is the execution context?
subprocess.check_output() from page 546
"Python Cookbook" 3rd Edition, David Beazley and Brian K. Jones, 2013,
O'Reily media, ISBN 978-1-4493-4037-7, http://www.dabeaz.com/cookbook.html
End of explanation
! nl -b a /etc/hosts | sed -n '74,77p;84,86p' | cut -c 1-100
Explanation: View of the network, private, from /etc/hosts
(/etc/hosts display truncated to avoid line wrap)
End of explanation
%cd '/Users/chrsclrk/Google Drive/solutionArchitect/automation' 
Explanation: Review of control machine's Ansible configuration
Let the Jupyter notebook know where to find files.
End of explanation
! echo "*** inventory.ini contents ***" ; nl -ba controlMachine/inventory.ini | sed -n '1,7p'
! echo "*** ansible.cfg contents ***" ; cat /Users/chrsclrk/.ansible.cfg
Explanation: Note use of group "aur" to provide value for "become" password.
End of explanation
!ansible aur --inventory=controlMachine/inventory.ini --module-name=ping
Explanation: is the control machine able to reach the remote machines?
Ansilble module, ping, replies with the string "ping" the control machine successfully connects with the host in the group aur.
End of explanation
!ansible aur --inventory=controlMachine/inventory.ini --module-name=command --args=uptime
Explanation: Here Ansible runs a program on the remote machines.
connectivity is established
uptime for the remote machines may be of interest than the string "pong".
End of explanation
oneSetup = !ansible aur[0] --inventory=controlMachine/inventory.ini --module-name=setup
print(f'{len(oneSetup):>34}  Metric of setup results; length of Jupyter reference to saved setup results.\n'
      f'{type(oneSetup)}  Type of Jupyter reference to save results.')
oneSetup  # View facts from the first target machine.
Explanation: Ansible's "setup" module; all it knows about a target machine
When Ansible's connects to a target machine it collects information as part of its setup.
The resulting data structure is collectively referred to as facts.
End of explanation
!ansible aur --inventory=controlMachine/inventory.ini --module-name=setup --args='filter=ansible_default_ipv4'
Explanation: Retrieve a subset of the facts.
From Loren Hochsetein's page
[https://github.com/lorin/ansible-quickref/blob/master/facts.rst]
End of explanation
    !ansible aur --inventory=controlMachine/inventory.ini --module-name=shell --args="date --rfc-3339=ns"
Explanation: Report the target machines' date for rough idea of time synchrony.
From the control machine, Ansible concurrently accesses the target machines.
This example shows the three target machines are within a 100 milliseconds of each other.
End of explanation
   !ansible aur --inventory=controlMachine/inventory.ini --module-name=shell --args="/usr/sbin/ip -4 addr show eno16777728 | sed -n '2p' | cut  -d ' ' -f 6"
Explanation: Results from piping commands on the remote machines.
Three commands on the target host to yield an IPv4 address of a network device.
(CentOS uses the “Predictable Network Interface Names” convention.)
End of explanation
! nl playbooks/ch04-98_facts_ip-mac.yaml
! ansible-playbook --verbose --inventory=controlMachine/inventory.ini --become playbooks/ch04-98_facts_ip-mac.yaml
Explanation: Ansible Playbooks
One playbook with one task and three debug statments concerning the network adapater Ansible is using by default."
Ansible's debug module is used to
*  print the IPv4 address
*  print the MAC address
*  print the IPv4 and MAC address togehter on one line
End of explanation
<END_TASK>