2017-12-15 2 views
0

Ich verwende ein Playbook, um ein Softwareprogramm zu deinstallieren und das Playbook funktioniert. Dieser Textbuch erster comfirms des binären Pfad der Software der stat Modul und die nutzen den when Zustand zu überprüfen, ob es und besteht aus, dass er die Aktionen ausführt ..ansibleUndefinedVariable Fehler beim Speichern von Protokollen in einer Datei

ich auch das shell Modul bin mit laufen die Deinstallation. Unten ist mein Textbuch

--- 
- name: Un-Install altris 
    hosts: all 
    gather_facts: False 
    strategy: free 
    serial: 100 
    tasks: 
    - name: Check if altris stop/start path exists 
    stat: path=/opt/altiris/notification/nsagent/bin/rcscript 
    register: altris_status 

    - name: stop the altris if path exits 
    shell: | 
     echo `hostname` 
     echo "-------------------------------" 
     /opt/altiris/notification/nsagent/bin/rcscript stop 
    when: altris_status.stat.exists == True 
    register: altris_stop 

    - name: Check if uninstall binary ptah exists 
    stat: path=/opt/altiris/notification/nsagent/bin/aex-uninstall 
    register: altris_uninstall 

    - name: un-installing altris 
    shell: | 
     echo `hostname` 
     echo "-------------------------------" 
     yes | /opt/altiris/notification/nsagent/bin/aex-uninstall 
    when: altris_uninstall.stat.exists == True 
    register: altris_trim 

############# Storing the logs locally for the STDOUT ############ 
    - name: Storing the remote Hosts Output locally for altris 
    #lineinfile: create=yes dest=/Karn/altris_uninstall.logs line="{{ altris_trim.stdout }}" 
    lineinfile: create=yes dest=/Karn/test_uninstall.logs line="{{ altris_trim.stdout }}" 
    delegate_to: 127.0.0.1 

    - name: Storing the remote Hosts Output locally for altris 
    #lineinfile: create=yes dest=/Karn/altris1_stop.logs line="{{ altris_stop.stdout }}" 
    lineinfile: create=yes dest=/Karn/test_stop.logs line="{{ altris_stop.stdout }}" 
    delegate_to: 127.0.0.1 

Hinweis: wenn ich das Textbuch seiner Werke gut laufen, aber der Fehler tritt nur auf, wo es nicht den binären Pfad für un-Installation und führt den unten mesg errror finden:

[[email protected] Karn]# ansible-playbook altris_unistall2.yml 

PLAY [Un-Install altris] ******************************************************************************************************************************************** 
Friday 15 December 2017 10:35:50 +0530 (0:00:00.112)  0:00:00.112 ******* 

TASK [Check if altris stop/start path exists] *********************************************************************************************************************** 
ok: [dev-oracle] 
Friday 15 December 2017 10:36:01 +0530 (0:00:10.179)  0:00:10.292 ******* 

TASK [stop the altris if path exits] ******************************************************************************************************************************** 
skipping: [dev-oracle] 
Friday 15 December 2017 10:36:01 +0530 (0:00:00.019)  0:00:10.311 ******* 

TASK [Check if uninstall binary ptah exists] ************************************************************************************************************************ 
ok: [dev-oracle] 
Friday 15 December 2017 10:36:11 +0530 (0:00:10.483)  0:00:20.795 ******* 

TASK [un-installing altris] ***************************************************************************************************************************************** 
skipping: [dev-oracle] 
Friday 15 December 2017 10:36:11 +0530 (0:00:00.022)  0:00:20.817 ******* 

TASK [Storing the remote Hosts Output locally for altris] *********************************************************************************************************** 
fatal: [dev-oracle]: FAILED! => { 
    "failed": true 
} 

MSG: 

The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'stdout' 

The error appears to have been in '/Karn/altris_unistall2.yml': line 33, column 5, but may 
be elsewhere in the file depending on the exact syntax problem. 

The offending line appears to be: 

############# Storing the logs locally for the STDOUT ############ 
    - name: Storing the remote Hosts Output locally for altris 
    ^here 

exception type: <class 'ansible.errors.AnsibleUndefinedVariable'> 
exception: 'dict object' has no attribute 'stdout' 

     to retry, use: --limit @/Karn/altris_unistall2.retry 

PLAY RECAP ********************************************************************************************************************************************************** 
dev-oracle    : ok=2 changed=0 unreachable=0 failed=1 

Friday 15 December 2017 10:36:11 +0530 (0:00:00.037)  0:00:20.854 ******* 
=============================================================================== 
Check if uninstall binary ptah exists ----------------------------------------------------------------------------------------------------------------------- 10.48s 
Check if altris stop/start path exists ---------------------------------------------------------------------------------------------------------------------- 10.18s 
Storing the remote Hosts Output locally for altris ----------------------------------------------------------------------------------------------------------- 0.04s 
un-installing altris ----------------------------------------------------------------------------------------------------------------------------------------- 0.02s 
stop the altris if path exits -------------------------------------------------------------------------------------------------------------------------------- 0.02s 

Bitte susggest falls vorhanden chnage ich in meinem Textbuch haben müssen .. so etwas wie ingore_error ..

Antwort

0

un-installing altris Aufgabe wird übersprungen, daher enthält altris_trim keine stdout Taste.

Sie müssen entweder when: stdout in altris_trim zur Storing the remote Hosts Output locally for altris hinzufügen oder die gleiche Bedingung wie für un-installing altris verwenden. Das gleiche gilt für die nächste Aufgabe und altris_stop.stdout.

Verwandte Themen