繁体   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