These are the initial commands that will help you get Ansible installed on your Raspberry Pi. I used the latest version of Debian Buster as a starting point.
• sudo apt-get update
• sudo apt-get upgrade
• sudo apt install ansible sshpass
cd /etc/ansible
sudo nano ansible.cfg
Remove # from host_key_checking
Cd /etc/ansible
Sudo nano hosts
[RPI]
10.0.1.2
10.0.1.3
[RPI:vars]
ansible_user=root
ansible_password=raspberry
—————————————
pi@Ansible:/etc/ansible $ ansible –version
ansible 2.7.7
config file = /etc/ansible/ansible.cfg
configured module search path = [‘/home/pi/.ansible/plugins/modules’, ‘/usr/share/ansible/plugins/modules’]
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.7.3 (default, Dec 20 2019, 18:57:59) [GCC 8.3.0]
—————————————-
# Ping the RPI’s in the group you created
ansible RPI -m ping
————————————
# Tail /var/log/messages
ansible RPI -m command -a “tail /var/log/messages”
Same command but from playbook (named log.yml)
—
– hosts: RPI
tasks:
– name: show last 10 lines of log
shell: tail /var/log/messages
Run the script as follows
Ansible-playbook log.yml
————————————
How to check for upgradeable modules
ansible RPI -a “apt list –upgradeable” -b
— update.yml playbook
– hosts: RPI
become: true
tasks:
– name: Using apt update the packages
apt:
upgrade: yes
update_cache: yes
Syntax to run – ansible-playbook update.yml
—————————————————–
“Reboot all RPIs”
ansible RPI -a “reboot”
Playbook sample
—
– name: Install Nano
hosts: RPI
tasks:
– name: install nano
apt:
name: nano
state: latest (change to absent to remove)
ansible-playbook name_of_playbook.yml
================================================
*** Show Notes, Links and Resources ****
Here are the items mentioned in this video –
LABISTS Raspberry Pi 4 Complete Starter Kit with Pi 4 Model B 1GB
https://amzn.to/32n9Gub
———————————–
Get Your SmartHome Device Checklist here –
http://eepurl.com/goDE49
➥➥➥ SUBSCRIBE FOR MORE VIDEOS ➥➥➥
Never miss a video about creating your own smart home
Subscribe ⇢ http://ronaldnutter.com/subscribe
To listen to an audio version of this episode while driving, TechBytes with Ron Nutter is available on iTunes, Google Podcasts, Stitcher and TuneIn. Go to TechByteswithRonNutter.com to subscribe today!
To subscribe to the TechbytesRN newsletter, click here – http://ronaldnutter.com/sample1
In return for subscribing to the newsletter, I will send you a chapter from my first DIY Smart Home Guide Book.
Visit http://www.ronaldnutter.com to see all the books Ron has written
DISCLAIMER: This video and description contains affiliate links, which means that if you click on one of the product links, I’ll receive a small commission. This helps support the channel and allows me to continue to make videos like this. Thank you for the support!
*===============================*
Become a Patreon supporter
https://www.patreon.com/techbytesrn
*===============================*
#TechBytesRN #smarthome #raspberrypi #rpi #ansible
Podcast: Play in new window | Download
Subscribe: Apple Podcasts | TuneIn | RSS