AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / unix / 问题 / 759606
Accepted
Hugh Warden
Hugh Warden
Asked: 2023-10-23 09:45:13 +0800 CST2023-10-23 09:45:13 +0800 CST 2023-10-23 09:45:13 +0800 CST

R 软件包无法通过 ansible 安装(ALMA Linux 8)

  • 772

问题

我想使用 ansible 来配置一个虚拟盒子。这个盒子需要做很多事情,但它需要安装 R 以及一些未包含在基础 R 中的特定软件包。

我使用下面提供的 vagrant 文件创建一个新的虚拟机,然后使用 yum 安装 ansible、epel-release 和 git。然后,在该虚拟机上,我使用下面提供的“Alma Linux 8”和“Docker”剧本,然后使用我认为有问题的剧本。

然后我运行这个剧本来安装 R

---
- name: "Setup R on the local machine"
  hosts: localhost
  connection: local 
  tasks:

  # Update all installed packages

  - name: Update all packages to their latest version
    become: yes
    ansible.builtin.package:
      name: "*"
      state: latest

  # Install EPEL to get extra packages

  - name: Install EPEL
    become: yes
    ansible.builtin.package:
      name: epel-release
      state: latest

  # Enable the Code Ready Builder (CRB) repository

  - name: Install utilities to enable package repositories
    become: yes
    ansible.builtin.package:
      name: yum-utils
      state: latest

  - name: Enable the PowerTools repository
    become: yes
    shell: dnf config-manager --set-enabled powertools

  # Install R

  - name: Install R
    become: yes
    ansible.builtin.package:
      name: R
      state: latest

运行此剧本后,我可以运行命令

Rscript --slave --no-save --no-restore-history -e "print('Test')"
[1] "Test"

表明 R 至少在某种程度上发挥着作用。但是当我尝试使用它来安装软件包时,我收到此错误

Rscript --slave --no-save --no-restore-history -e "install.packages('tidyverse')"

将软件包安装到“/usr/lib64/R/library”(因为未指定“lib”) install.packages(“tidyverse”) 中出现警告:“lib =“/usr/lib64/R/library””不可写错误在 install.packages("tidyverse") 中:无法安装包执行停止

尝试修复

我尝试通过将这些行附加到上面 R 剧本的末尾来解决此问题

- name: Make directory writable
  become: yes
  file:
    path: /usr/lib64/R/library
    mode: '0777'

- name: Make directory writable
  become: yes
  file:
    path: /usr/share/doc/R/html
    mode: '0777'

手动使有问题的目录可读,但这不起作用。

参考文件

流浪文件

Vagrant.configure("2") do |config|

    config.vm.box = "almalinux/8"

    config.vm.provider "virtualbox" do |vb|
        vb.memory = "2048"
        vb.cpus = 2
    end
    
end

Ansible 手册

阿尔玛Linux 8

---
- name: "Setup AlmaLinux 8 on the local machine"
  hosts: localhost
  connection: local
  tasks:

  # Install the base operating systemctl

  - name: Update all packages to their latest versions
    become: yes
    ansible.builtin.package:
      name: '*'
      state: latest

  - name: Install virtual machine support
    become: yes
    ansible.builtin.package:
      name: open-vm-tools
      state: latest

  # Install EPEL to get extra packages

  - name: Install EPEL
    become: yes
    ansible.builtin.package:
      name: epel-release
      state: latest

码头工人

---
- name: "Setup Docker on the local machine"
  hosts: localhost
  connection: local 
  tasks:

  # Install Docker

  - name: Uninstall any older versions of Docker
    become: yes
    ansible.builtin.package:
      name:
        - docker
        - docker-client
        - docker-client-latest
        - docker-common
        - docker-latest
        - docker-latest-logrotate
        - docker-logrotate
        - docker-engine
      state: absent

  - name: Install yum-utils to install a new package repository
    become: yes
    ansible.builtin.package:
      name: yum-utils
      state: latest

  - name: Install the Docker Repository
    become: yes
    shell: yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

  - name: Install Docker
    become: yes
    ansible.builtin.package:
      name:
        - docker-ce
        - docker-ce-cli
        - containerd.io
        - docker-buildx-plugin
        - docker-compose-plugin
      state: latest

  - name: Enable the docker service
    become: yes
    shell: systemctl enable docker

  - name: Enable the containerd service
    become: yes
    shell: systemctl enable containerd

  - name: Start the docker service
    become: yes
    shell: systemctl start docker

  - name: Start the containerd service
    become: yes
    shell: systemctl start containerd

  - name: Ensure docker group exists
    become: yes
    ansible.builtin.group:
      name: docker
      state: present

  - name: Add the vagrant user to the docker group
    become: yes
    ansible.builtin.user:
      name: vagrant
      groups: docker
      append: yes
ansible
  • 1 1 个回答
  • 20 Views

1 个回答

  • Voted
  1. Best Answer
    Marcus Müller
    2023-10-23T11:38:27+08:002023-10-23T11:38:27+08:00

    但是当我尝试使用它来安装软件包时

    您以普通用户身份执行此操作,但尝试安装到系统目录中,这就是问题所在。

    您想在系统范围内安装吗?然后以 root 身份执行此操作。您只需要该一位用户的软件包吗?然后不要在系统范围内安装。

    • 0

相关问题

  • 在ansible中跳过一些带有提示的任务[关闭]

  • ansible中事实变量的分隔符值

  • 剧本给出语法错误

  • sshpass 在 alpine linux 中不起作用

  • Ansible shell 模块空响应

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    模块 i915 可能缺少固件 /lib/firmware/i915/*

    • 3 个回答
  • Marko Smith

    无法获取 jessie backports 存储库

    • 4 个回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    user12345 无法获取 jessie backports 存储库 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl 为什么大多数 systemd 示例都包含 WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve