通过ansib使用conda命令的Bug

2024-09-29 23:33:15 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试通过ansible角色自动安装Miniconda。 我没有粘贴整个错误,因为我试图理解那些权限错误,希望这是真正的问题,我不明白为什么康达试图创建路径为/.cph\u xxx的文件或文件夹。 如果有人已经有这个问题,我真的很想知道。 我的工作描述起来有点复杂,我正在用分子测试一个可能的角色。所有这些代码都在RHEL7 Docker容器中执行。你知道吗

这是我的任务/主.yml角色中的文件:

---
# necessary steps to deploy the role.
- name: 'Add the user {{ miniconda_user }} with a bash shell'
  user:
    name: '{{ miniconda_user }}'
    shell: /bin/bash

- name: check if already installed
  stat: path={{ miniconda_home }}/bin/conda
  register: bin_conda
  changed_when: bin_conda.stat.exists == False
  become: yes
  become_user: '{{ miniconda_user }}'

- name: Create a tmp directory if it does not exist
  file:
    path: '{{ miniconda_tmp }}'
    state: directory
    mode: '0755'
  become: yes
  become_user: '{{ miniconda_user }}'

- name: download miniconda installer
  get_url:
    url={{ miniconda_url }}
    dest={{ miniconda_tmp }}/miniconda.sh
    mode=0755
  register: miniconda_downloaded
  when: bin_conda.stat.exists == False
  become: yes
  become_user: '{{ miniconda_user }}'

- name: install miniconda
  shell: '{{ miniconda_tmp }}/miniconda.sh -b -f -p {{ miniconda_home }}'
  register: miniconda_installed
  when: miniconda_downloaded | success
  become: yes
  become_user: '{{ miniconda_user }}'

- name: remove miniconda setup script
  file: name={{ miniconda_tmp }}/miniconda.sh state=absent
  when: miniconda_installed | success
  become: yes
  become_user: '{{ miniconda_user }}'

- name: Recursively change ownership of Miniconda a directory
  file:
    path: '{{ miniconda_home }}'
    state: directory
    recurse: yes
    mode: '0755'
    owner: '{{ miniconda_user }}'
    group: '{{ miniconda_user }}'

- name: update miniconda
  shell: '{{ miniconda_conda_bin }} update --all'
  register: miniconda_installed
  when: miniconda_downloaded | success
  become: yes
  become_user: '{{ miniconda_user }}'

我不明白的是,最后一步conda update给出了以下错误,尽管之前的每一步都有效:

fatal: [instance]: FAILED! => {
  "changed": true, 
  "cmd": "/home/proxirhmanager/miniconda/bin/conda update --all", 
  "delta": "0:00:08.547853", "end": "2019-10-01 09:14:57.246143", 
  "msg": "non-zero return code", 
  "rc": 1, 
  "start": "2019-10-01 09:14:48.698290", 
  "stderr": "
  [Errno 13] Permission denied: '/.cph_tmp05aumjox'
  [Errno 13] Permission denied: '/.cph_tmp4au09jia'
  [Errno 13] Permission denied: '/.cph_tmp33mgqg0y'
  [Errno 13] Permission denied: '/.cph_tmpo10r_iv1'
  [Errno 13] Permission denied: '/.cph_tmpnbwz5bvs'
  "

Tags: installednamebinshellcondatmpyespermission

热门问题