實際操作測試1 - 使用ssh
以下是小編在看Udemy前的實作測試
Configure ssh
ssh-keygen -t rsa
ssh-copy-id -i ~/.ssh/id_rsa.pub username@host
# in case you cannot do the pubkey auth, do this and it may help:
chmod g-w /home/your_user
chmod 700 /home/your_user/.ssh
chmod 600 /home/your_user/.ssh/authorized_keysAnsible Inventory Configuration
in /etc/ansible, edit hosts :
[apache] # it is a group name of these servers
# you can specify the user and ssh port number of this server
# Inventory Parameters
# ansible_connection=ssh/winrm/local
# ansible_port=22
# ansible_user=root/administrator
# ansible_ssh_pass=password
apache2 [email protected] ansible_port=22
*Try to ping the remote server
SUCCESS means we can ping the remote server.
*Check date of all remote servers
Writing Ansible Playbook
let's take an easy one for writing the playbook!
Create a .yml file in /etc/ansible first. For example, I am going to create a apache.ymlfile:
Run the .yml file
We add task and handler for apache:
It will update the status of remote server
Last updated
Was this helpful?