<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                > 1. command模塊,用來在遠程主機上執行命令 > 2. 使用 command 模塊在遠程主機中執行命令時,不會經過遠程主機的 shell 處理,在使用 command 模塊時,如果需要執行的命令中含有重定向、管道符等操作時,這些符號也會失效,比如”<”, “>”, “|”, “;” 和 “&” 這些符號,如果你需要這些功能,可以參考后面介紹的 shell 模塊。 > 3. 如果遠程節點是 windows 操作系統,則需要使用 win_command 模塊。 > 執行 ansible 時,不加 -m 默認使用 command ,可以在 /etc/ansible/ansible.cfg 中修改。 ``` # default module name for /usr/bin/ansible #module_name = command ``` ## 1. 選項 ### free_form參數 : > 必須參數,指定需要遠程執行的命令。需要說明一點,free_form 參數與其他參數(如果想要使用一個參數,那么則需要為這個參數賦值,也就是name=value模式)并不相同。比如,當我們想要在遠程主機上執行 ls 命令時,我們并不需要寫成”free_form=ls” ,這樣寫反而是錯誤的,因為并沒有任何參數的名字是 free_form,當我們想要在遠程主機中執行 ls 命令時,直接寫成 ls 即可。因為 command 模塊的作用是執行命令,所以,任何一個可以在遠程主機上執行的命令都可以被稱為 free_form。 ### chdir參數 : > 此參數的作用就是指定一個目錄,在遠程主機執行對應的命令之前,會先進入到 chdir 參數指定的目錄中。 ### creates參數 : > 看到 creates,你可能會從字面上理解這個參數,但是使用這個參數并不會幫助我們創建文件,它的作用是當指定的文件存在時,就不執行對應命令,比如,如果 /testdir/test文件存在,就不執行我們指定的命令。 ### removes參數 : > 與 creates 參數的作用正好相反,它的作用是當指定的文件不存在時,就不執行對應命令,比如,如果 /testdir/tests 文件不存在,就不執行我們指定的命令,此參數并不會幫助我們刪除文件。 ``` [root@ansible-manager ~]# ansible ansible-demo3 -m command -a "ls" ansible-demo3 | SUCCESS | rc=0 >> anaconda-ks.cfg CentOS7-Base-163.repo Centos-7.repo ``` > 上面命令表示在 ansible-demo3 主機上執行 ls 命令,因為使用的是 root 用戶,所以默認情況下,ls 出的結果是 ansible-demo3 主機中 root 用戶家目錄中的文件列表。 > ``` [root@ansible-manager ~]# ansible ansible-demo3 -m command -a "chdir=/testdir ls" ansible-demo3 | SUCCESS | rc=0 >> testfile1 testfile2 ``` > chdir 參數表示執行命令之前,會先進入到指定的目錄中,所以上面命令表示查看 ansible-demo3 主機上 /testdir 目錄中的文件列表,返回顯示有2個文件。 ``` [root@ansible-manager ~]# ansible ansible-demo3 -m command -a "creates=/testdir/testfile1 echo test" ansible-demo3 | SUCCESS | rc=0 >> skipped, since /testdir/testfile1 exists [root@ansible-manager ~]# ansible ansible-demo3 -m command -a "creates=/testdir/testfile3 echo test" ansible-demo3 | SUCCESS | rc=0 >> test ``` 上面命令表示 /testdir/testfile1 文件存在于遠程主機中,則不執行對應命令。/testdir/testfile3 不存在,才執行”echo test”命令。 ``` [root@ansible-manager ~]# ansible ansible-demo3 -m command -a "removes=/testdir/testfile1 echo test" ansible-demo3 | SUCCESS | rc=0 >> test [root@ansible-manager ~]# ansible ansible-demo3 -m command -a "removes=/testdir/testfile3 echo test" ansible-demo3 | SUCCESS | rc=0 >> skipped, since /testdir/testfile3 does not exist ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看