2017-12-01 6 views
0

は、私は次のansible脚本を持っている:python2.7を必要としない、実行可能なタスクの例?

- hosts: myhosts 
    gather_facts: no 

    tasks: 
    - debug: 
     msg: just a test message 

私は、コマンドラインから、私が得ることを実行します。

PLAY RECAP **************************************************************************************************************** 
localhost     : ok=1 changed=0 unreachable=0 failed=0 

だからだけで正常に動作しています。しかし、私は追加した場合:私はAnsibleは、その機能のほとんどのpython2.7を必要とGoogleで検索したものから

TASK [Another task] ******************************************************************************************************* 
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Shared connection to localhost closed.\r\n", "module_stdout": "/bin/sh: 1: /usr/bin/python: not found\r\n", "msg": "MODULE FAILURE", "rc": 0} 
    to retry, use: --limit @/home/user/sandbox/ansible-vps/foo.retry 

PLAY RECAP **************************************************************************************************************** 
localhost     : ok=1 changed=0 unreachable=0 failed=1 

- 私は現在インストールされていない:それはで失敗

- hosts: myhosts 
    gather_facts: no 


    tasks: 
    - debug: 
     msg: just a test message 
    - name: Another task 
     command: echo "Do whatever you want to" 

。上記のエラーは、Python2.7やその他のものがないために発生しますか?

答えて

2

だから

はいPython2.7

の欠落に起因する上記のエラーです。 rawscript:Ansibleを除くほぼすべてのモジュールのためのPythonが必要です。

rawモジュールでPythonをインストールしてから、他のタスクを続行できます。 this answerを参照してください。 Pythonの必要はないタスクの

例:私はあなたが例を更新し実行すると、

- hosts: myhosts 
    gather_facts: no 
    tasks: 
    - debug: 
     msg: just a test message 
    - name: Another task 
     raw: /bin/bash -c 'some-command with-parameter' 
     register: cmd_res 
    - debug: 
     msg: "{{ cmd_res.stdout }}" 
+0

[OK]を - 代わりに、コマンドの生の使用 - テキストは、コンソールに出力されていない「あなたがしてやりたいです」それはちょうど変更されたと言う:[localhost]。ですから、リモートでbashコマンドを実行するためにrawをどのように使用しますか? – u123

+0

私は結果を確認するためにデバッグ出力で例を更新しました。あるいは、冗長表示( '-vv')を強くして、モジュール出力を見ることができます。 –

関連する問題