Имеется Vagrantfile
ip = "192.168.33.198";
Vagrant.configure("2") do |config|
config.vm.network "forwarded_port", guest: 80, host: 80
config.vm.network "forwarded_port", guest: 443, host: 443
config.vm.box = "centos/7"
config.vm.hostname = "zabbix"
config.vm.define "zabbix"
config.vm.network "private_network", ip: ip
config.vm.provider "virtualbox" do |vb|
vb.memory = "3096"
end
config.vm.provision "ansible" do |ansible|
ansible.playbook = "playbook.yml"
end
end
playbook.yml
- hosts: all
become: yes
roles:
- { role: dj-wasabi.zabbix-agent }
Вот блок кода, где ошибка:
- name: "Install local python-netaddr package"
pip:
name: netaddr
state: present
register: zabbix_python_netaddr_package_installed
until: zabbix_python_netaddr_package_installed is succeeded
delegate_to: localhost
become: "{{ zabbix_agent_become_on_localhost }}" - это True
when:
- zabbix_install_pip_packages | bool
- ansible_all_ipv4_addresses is defined or (zabbix_agent_ip is not defined and total_private_ip_addresses is defined)
Выдает ошибку:
TASK [dj-wasabi.zabbix-agent : Install local python-netaddr package] ***********
FAILED - RETRYING: Install local python-netaddr package (3 retries left).
FAILED - RETRYING: Install local python-netaddr package (2 retries left).
FAILED - RETRYING: Install local python-netaddr package (1 retries left).
fatal: [zabbix -> localhost]: FAILED! => {"attempts": 3, "changed": false, "module_stderr": "sudo: требуется пароль\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
Имеется второй playbook.yml
- hosts: all
become: yes
gather_facts: yes
tasks:
- name: test which user I am
shell: whoami
register: hello
- debug: msg="{{ hello.stdout }}"
- name: Install EPEL repo.
yum:
name: epel-release
state: present
- name: Install python-pip
yum:
name: python-pip
state: present
- name: "Install local python-netaddr package"
pip:
name: netaddr
state: present
register: netaddr_installed
become: True
- debug: msg="{{ netaddr_installed.stdout }}"
Не выдает ошибку.
TASK [Install local python-netaddr package] ************************************
changed: [zabbix]
TASK [debug] *******************************************************************
ok: [zabbix] => {
"msg": "Collecting netaddr\n Downloading https://files.pythonhosted.org/packages/ba/97/ce14451a9fd7bdb5a397abf99b24a1a6bb7a1a440b019bebd2e9a0dbec74/netaddr-0.7.19-py2.py3-none-any.whl (1.6MB)\nInstalling collected packages: netaddr\nSuccessfully installed netaddr-0.7.19\n"
}
Почему в одном случае установка pip пакета через ansible в Vagrant требует sudo прав, а в другом нет?
Спасибо