I installed the ansible via pip install
, and there are several issues here:
where is the config
Here you should create a file ~/.ansible.cfg
[defaults]
inventory =~/.ansible/hosts
sudo_user=root
remote_port=22
host_key_checking=False
remote_user=root
log_path=~/.ansible/log/ansible.log
module_name=command
private_key_file=~/.ssh/id_rsa
Make a dir to store logs: mkdir ~/.ansible/log/
Need servers to run a test command
- I create a virtual server with VirtualBox and linux image with
archlinux-2019.07.01-x86_64.iso
- Set the network to
Bridged Adapter
, which using theWiFi-AirPort
in the Name selection. - Then clone the server as a second server.
- Start the network service, and check the ip address.
192.168.0.102
and192.168.0.103
- Change the root password with
passwd
- Now on the MacOS, exec
ssh-keygen -t rsa
to generate a new ssh identity - Exec
ssh-copy-id root@192.168.0.102
store the server's password locally. - vi ~/.ansible/hosts and put the content here.
[vmserver]
192.168.0.102
192.168.0.103
Let's run
ansible -m ping all
, ignore the WARNING :)