2017-01-26 2 views
0

Ich bin mir nicht sicher, was ich hier fehlt.Ansible Benachrichtigen Syntax Problem - Name^keine Aktion in Aufgabe

ansible 2.1.2.0

Python 2.7.5

CentOS Linux-Version 1511.07.02 (Core)

Textbuch Datei wie folgt aussieht:

[[email protected] ~/aks/netdata_ansible/ansible] $ cat netdata.yml 

--- 
- hosts: all 
    gather_facts: no 

    roles: 
    - netdata 

[[email protected] ~/aks/netdata_ansible/ansible] $ 

Die Rolle (NETDATA) main.yml wie folgt aussieht:

[[email protected] ~/aks/netdata_ansible/ansible] $ cat roles/netdata/tasks/main.yml 

--- 
# ansible-playbook -i 

#- name: Netdata details 
# debug: 
# msg: "server = {{ netdata_server }}" 
## 
#- name: Check if netdata systemctl is running 
# command: "systemctl status netdata" 
# ignore_errors: yes 
# register: netdata_systemctl_status 
# 
#- name: Report status of Netdata Service 
# debug: 
# msg: "{{ netdata_systemctl_status.stdout_lines }}" 
# 
- name: Start netdata systemctl if it is not running 
    debug: 
    msg: "Restarting netdata systemctl now" 
    notify: restart netdata systemctl 

    #when: netdata_systemctl_status | failed 

[[email protected] ~/aks/netdata_ansible/ansible] $ 

Handler den Antragsteller benachrichtigt und es ist Haupt-Datei wie folgt aussieht:

[[email protected] ~/aks/netdata_ansible/ansible] $ cat roles/netdata/handlers/main.yml 

--- 
# PS. 
# Order of listing notifiers in this file matters. 
# Order of listing notifiers while calling/notifying a notifier in a task/action doesn't. 

- name: restart netdata systemctl 
    systemd: 
    name: netdata 
    state: restarted 

[[email protected] ~/aks/netdata_ansible/ansible] $ 

Dann warum ansible mir die folgende Fehlermeldung?

[[email protected] ~/aks/netdata_ansible/ansible] $ ansible-playbook -i "`hostname`," --connection=local netdata.yml 
ERROR! no action detected in task. This often indicates a misspelled module name, or incorrect module path. 

The error appears to have been in '/home/vagrant/aks/netdata_ansible/ansible/roles/netdata/handlers/main.yml': line 6, column 3, but may 
be elsewhere in the file depending on the exact syntax problem. 

The offending line appears to be: 


- name: restart netdata systemctl 
^here 


The error appears to have been in '/home/vagrant/aks/netdata_ansible/ansible/roles/netdata/handlers/main.yml': line 6, column 3, but may 
be elsewhere in the file depending on the exact syntax problem. 

The offending line appears to be: 


- name: restart netdata systemctl 
^here 

[[email protected] ~/aks/netdata_ansible/ansible] $ 
+0

Mögliches Duplikat von [Warum zeigt Ansible "FEHLER! Keine Aktion in Aufgabe gefunden"?] (Https://stackoverflow.com/questions/47159193/why-does-ansible-show-error-no-action- detected-in-task-error) – techraf

Antwort

1

Die systemd module wurde in Ansible 2.2 eingeführt.

systemd - Dienste verwalten.

Neu in Version 2.2.

Sie verwenden Ansible 2.1.2 daher Ansible meldet keine bekannte Aktion in der Task definiert ist.

+0

dang it .. danke @techraf. Ich habe die Betreffzeile geändert, um diese "keine bekannte Aktion" widerzuspiegeln. –

+0

Kann Ansible sich immer zuerst selbst aktualisieren (auf eine bestimmte Version), wenn eine Rolle/ein Playbook etwas verwendet, das in Ansible x.y + verfügbar ist? oder ich denke, ich muss das in der Dokumentation selbst für mein Spielbuch/meine Rolle klären. –

+0

Ich schätze, dass nicht viele Leute automatische Updates schätzen würden. Prüfe das für andere Ideen [Erfordert mindestens eine Ansible-Version in deinem Playbook] (https://www.jeffgeerling.com/blog/2016/require-minimum-ansible-version-your-playbook) – techraf