Код: Выделить всё
ansible.cfgКод: Выделить всё
[defaults]
inventory = hosts.ini
remote_user = abin
Код: Выделить всё
hosts.iniКод: Выделить всё
[webservers]
192.168.64.9
Код: Выделить всё
install_nginx.ymlКод: Выделить всё
- name: Install Nginx
hosts: webservers
become: true
tasks:
- name: Install Nginx
apt:
name: nginx
state: present
- name: Ensure Nginx is running
service:
name: nginx
state: started
enabled: yes
Код: Выделить всё
abin@webserver1:~$ sudo whoami
root
Код: Выделить всё
ansible-playbook install_nginx.yml --check --diff
PLAY [Install Nginx] *****************************************************************************************************************************************************************************************
TASK [Gathering Facts] ***************************************************************************************************************************************************************************************
[WARNING]: Host '192.168.64.9' is using the discovered Python interpreter at '/usr/bin/python3.12', but future installation of another Python interpreter could cause a different interpreter to be discovered. See https://docs.ansible.com/ansible-core/2.20/reference_appendices/interpreter_discovery.html for more information.
[ERROR]: Task failed: Missing sudo password
fatal: [192.168.64.9]: FAILED! => {"changed": false, "msg": "Task failed: Missing sudo password"}
PLAY RECAP ***************************************************************************************************************************************************************************************************
192.168.64.9 : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
Подробнее здесь: https://stackoverflow.com/questions/798 ... o-password
Мобильная версия