If your managed hosts are running an rpm-based version of Linux, replace the last line with yum: name=mc state=latest. $ sudo nano /etc/ansible/playbooks/mc-deploy.yml - hosts: servers_all ![]() Let’s have a look at an example of a simple playbook to install the Midnight Commander (mc) file manager on the hosts. Ansible checks that the managed host configuration matches the description in the playbook. ![]() In the playbook, you can describe the desired state of the system. You can either send commands to the managed hosts through the console (ad-hoc) or by using a special YAML playbook file. $ ansible -m shell -a 'uptime' all Working with Ansible Playbooks Now we use the shell module to check the uptime of all the hosts: $ ansible -m setup -a 'filter=ansible_memtotal_mb' all In this example, we only need information about the hosts’s RAM: Let’s look at some examples of interactive command execution on hosts in the inventory file.įirst, we’ll run an inventory procedure to check the state of the hosts. Let’s check the uptime of all servers in the servers_all group: Now you can use Ansible to run remote commands without entering a password. We specify our local copy of /.ssh/idrsa.pub, the public key in our SSH directory, and upload it to the remote users directory under the authorizedkeys file. ssh without entering a password every time. # nano /etc/ssh/sshd_config PubkeyAuthentication yes ssh-copy-id userhost :port will copy the keys Method-1: Using scp with. ![]() This can be done manually by calling ssh-copy-id userserverB on serverA. Make sure that SSH key-based authentication is enabled on remote hosts: Ansible authorizedkey module to copy SSH key fails with sshpass needed erro.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |