A
A
apaicer2021-08-11 15:06:20
linux
apaicer, 2021-08-11 15:06:20

Ansible not starting role?

Hello.

Understanding Ansible and roles.

Created a role to install Apache.

As a separate playbook it starts without problems, but as a role it does not work normally.

Mistake:

ansible-playbook playbook_roles_apache.yml 

PLAY [Install Apache] ************************************************************************************************************************************************************************************************************************

TASK [Gathering Facts] ***********************************************************************************************************************************************************************************************************************
[WARNING]: Platform linux on host debvm is using the discovered Python interpreter at /usr/bin/python, but future installation of another Python interpreter could change this. See
https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information.
ok: [debvm]
ok: [vps-ubuntu]
ok: [centosvm]

TASK [deploy_apache : Install Apache] ********************************************************************************************************************************************************************************************************
fatal: [debvm]: FAILED! => {"ansible_facts": {"pkg_mgr": "apt"}, "changed": false, "msg": "value of state must be one of: absent, build-dep, fixed, latest, present, got: installed"}
fatal: [vps-ubuntu]: FAILED! => {"ansible_facts": {"pkg_mgr": "apt"}, "changed": false, "msg": "value of state must be one of: absent, build-dep, fixed, latest, present, got: installed"}
ok: [centosvm]

TASK [deploy_apache : Apache UP] *************************************************************************************************************************************************************************************************************
ok: [centosvm]

TASK [deploy_apache : Install Apache Debian] *************************************************************************************************************************************************************************************************
[WARNING]: Updating cache and auto-installing missing dependency: python-apt
fatal: [centosvm]: FAILED! => {"changed": false, "cmd": "apt-get update", "msg": "[Errno 2] Нет такого файла или каталога", "rc": 2}

PLAY RECAP ***********************************************************************************************************************************************************************************************************************************
centosvm                   : ok=3    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
debvm                      : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
vps-ubuntu                 : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0


In the role I have only task.

---
# tasks file for deploy_apache
- block: #Block for Centos 
    - name: Install Apache
      yum: name=httpd state=installed
    - name: Apache UP 
      service: name=httpd state=started enabled=yes
      when: ansible_os_family == "RedHat"

- block: #Block for Debian
    - name: Install Apache Debian
      apt: name=apache2 update_cache=yes state=latest
    - name: Apache UP Debian
      service: name=apache2 state=started enabled=yes
      when: ansible_os_family == "Debian"


Tell me what I'm doing wrong?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Ivanov, 2021-08-11
@apaicer

The Install Apache Debian task does not have when: ansible_os_family == "Debian" and it runs on centos. The Install Apache task has the same error, but it just works on centos.

P
Puma Thailand, 2021-08-11
@opium

So your art is not on the server, put it first

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question