Linux/Ansible: Difference between revisions

From Wiki
mNo edit summary
mNo edit summary
Line 15: Line 15:
</pre>
</pre>


* Install plugins
<pre>
ansible-galaxy collection install ansible.posix
</pre>


= Commands =
= Commands =

Revision as of 10:32, 8 December 2021

Other articles

Install

sudo apt update
sudo apt install ansible  
  • Install plugins
ansible-galaxy collection install ansible.posix 

Commands

ansible --version
ansible-playbook pb-machinex.yml
ansible hostname -m setup    # variables for "hostname"


Step-by-step

  1. Setup file structure
  2. When using ssh key access
    ssh-copy-id -i ~/.ssh/id_rsa user@server
  3. When using ssh password
    apt install sshpass
    ansible-galaxy collection install ansible.posix    # when using ansible to set ssh key
  4. Run ansible playbook
    ansible-playbook pb-hostname.yml
    options:
    -k (ssh pass)
    -K (password for sudo)

Links