Trace: ansible

ansible

This is an old revision of the document!


Back  
 Next

ansible

  • sudo apt install sshpass The sshpass package must be installed.
  • Create a file ansible.cfg in your current folder with the following contents:
[defaults]
host_key_checking = false
  • create password less login to remote machines
    • ssh-keygen will create an ssh key pair
    • ssh-copy-id -i ~/.ssh/id_rsa.pub userp@remote.local.machine.io to copy the public key to the remote machine for same user.
  • cd /mnt/ansible These commands only work in this directory or with full paths
  • ansible-inventory -i inventory.ini --list Lists the current inventory
  • ansible-playbook -i inventory.ini debian_update.yml --become-password-file '/mnt/ansible/password.yml'
  • ansible all -m gather_facts -i inventory.ini --tree /tmp/facts
  • ansible all -i inventory.ini -m ping -u user
  • ansible -i inventory.ini kpts -a “ls -la ~” -u user
  • ansible -i inventory.ini kpts -a “df -h” -u user
  • ansible all -i inventory.ini -a “df -h” -u user
  • crontab -l
  • 5 4 * * 6 ansible-playbook /mnt/ansible/debian_update.yml -i /mnt/ansible/inventory.ini --become-password-file '/mnt/ansible/password.yml'

I should check about setting up ansible to save some time maintaining my servers.


Back  
 Next
/app/www/public/data/attic/tech_notes/ansible.1710335913.txt.gz · Last modified: 2024-03-13 Wed wk11 21:18
CC Attribution-Share Alike 4.0 International Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International