簡體   English   中英

康達沒有使用ansible劇本進行初始化

[英]conda not getting initialize using ansible playbook

我正在使用ansible自動化conda安裝,但是激活conda的最后一步(conda init)失敗了。

我嘗試運行conda init,因為shell腳本和命令模塊全部失敗。

碼:

---
  - hosts: all
    gather_facts: true
    tasks:
     - name: Ansible copy file to remote server
       copy:
         src: ~/Downloads/Anaconda3-2019.03-Linux-x86_64.sh
         dest: ~/Downloads/Anaconda3-2019.03-Linux-x86_64.sh
     - name: Run the installer Anaconda
       command: bash ~/Downloads/Anaconda3-2019.03-Linux-x86_64.sh -b 
     - name: add path
       shell: export PATH=~/anaconda3/bin:$PATH
     - name: initialize conda
       shell: init conda
       args:
        executable: /bin/bash

錯誤:

  • “ stderr”:“預期的單字符參數。”,“ stderr_lines”:
  1. 看來您執行的命令錯誤。 它應該是“ conda init”而不是“ init conda”

  2. 您可以將兩個Shell任務組合在一起並可以執行它。 更新后的代碼如下:

---
  - hosts: all
    gather_facts: true
    tasks:
     - name: Ansible copy file to remote server
       copy:
         src: ~/Downloads/Anaconda3-2019.03-Linux-x86_64.sh
         dest: ~/Downloads/Anaconda3-2019.03-Linux-x86_64.sh
     - name: Run the installer Anaconda
       command: bash ~/Downloads/Anaconda3-2019.03-Linux-x86_64.sh -b 

     - name: Add path and initialize conda
       shell: export PATH=~/anaconda3/bin:$PATH && conda init
       args:
        executable: /bin/bash

shell模塊設置的變量PATH僅在此任務(shell會話)中可用。 嘗試

shell: "export PATH=~/anaconda3/bin:$PATH; init conda"
args:
  executable: /bin/bash

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM