$ sudo vi /etc/ansible/ansible.cfg
# uncomment this to disable SSH key host checking
host_key_checking = False
$ sudo vi /etc/ansible/hosts
[awsec2instances]
10.2.0.39
10.2.0.217
10.2.0.208
$ chmod 600 my-key.pem
$ ansible-playbook --private-key my-key.pem -u ec2-user ansible_playbook-aws-install-docker-2021.yml
Hi,
see
state: latest
https://docs.ansible.com/ansible/latest/collections/ansible/builtin/yum_module.html#parameter-state
It will also install the package if it's not already installed.
If the package is already installed and it's version is the latest one then ansible will do nothing.