在CentOS 7上通过Ansible的yum安装Xfce。

huangapple go评论83阅读模式
英文:

Installing Xfce on CentOS 7 via ansible yum

问题

I have a Centos 7 machine freshly started from the centos/7 vagrant base box. I provision the box via ansible but the following does not work:

- name: Install xfce
  yum:
    name: "Xfce"
    state: present
    enablerepo: "epel"

The error is:

TASK [desktop : Install xfce]
************************************************** fatal: [xxx]: FAILED! => {"changed": false,
"changes": {"installed": ["Xfce"]}, "msg": "Error: Nothing to do\n",
"rc": 1, "results": ["Loaded plugins: fastestmirror\nLoading mirror
speeds from cached hostfile\n * base: mirror.ratiokontakt.de\n * epel:
mirror.de.leaseweb.net\n * extras: centos.schlundtech.de\n * updates:
centos.schlundtech.de\n"]}

Yet, running the following command from within the machine works:

sudo yum --enablerepo=epel -y groups install "Xfce"

What am I doing wrong?

英文:

I have a Centos 7 machine freshly started from the centos/7 vagrant base box. I provision the box via ansible but the following does not work:

- name: Install xfce
  yum:
    name: "@^Xfce"
    state: present
    enablerepo: "epel"

The error is:

> TASK [desktop : Install xfce]
> ************************************************** fatal: [xxx]: FAILED! => {"changed": false,
> "changes": {"installed": ["@^Xfce"]}, "msg": "Error: Nothing to do\n",
> "rc": 1, "results": ["Loaded plugins: fastestmirror\nLoading mirror
> speeds from cached hostfile\n * base: mirror.ratiokontakt.de\n * epel:
> mirror.de.leaseweb.net\n * extras: centos.schlundtech.de\n * updates:
> centos.schlundtech.de\nGroup Xfce does not exist.\n"]}

Yet, running the following command from within the machine works:

sudo yum --enablerepo=epel -y groups install "Xfce"

What am I doing wrong?

答案1

得分: 3

根据yum模块文档

Yum本身有两种类型的组。 "包组" 在rpm本身中指定,而 "环境组" 在单独的文件中指定(通常由发行版提供)。不幸的是,这个区分对ansible用户来说是显而易见的,因为ansible需要在单个事务中操作一组软件包,而yum在这种情况下需要以不同的方式指定组。包组被指定为 "@development-tools",而环境组被指定为 "@^gnome-desktop-environment"。使用 "yum group list hidden ids" 命令查看要安装的组属于哪个类别的组。

你正在将你的组指定为@^Xfce,这是"环境组" 的语法,但如果你查看yum group list hidden ids的输出,你会发现没有"Xfce"环境组。确实有一个同名的包组,而且这个playbook似乎成功安装了它:

---
- hosts: localhost
  gather_facts: false
  tasks:
    - name: 安装xfce
      yum:
        name: "@Xfce"
        state: "present"
        enablerepo: "epel"
英文:

According to the yum module documentation:

> Yum itself has two types of groups. “Package groups” are specified in the rpm itself while “environment groups” are specified in a separate file (usually by the distribution). Unfortunately, this division becomes apparent to ansible users because ansible needs to operate on the group of packages in a single transaction and yum requires groups to be specified in different ways when used in that way. Package groups are specified as “@development-tools” and environment groups are “@^gnome-desktop-environment”. Use the “yum group list hidden ids” command to see which category of group the group you want to install falls into.

You're specifying your grouop as @^Xfce, which is the syntax for an "environment group", but if you look at the output of yum group list hidden ids there is no "Xfce" environment group. There is a package group by that name, and this playbook seems to install it successfully:

---
- hosts: localhost
  gather_facts: false
  tasks:
    - name: install xfce
      yum:
        name: "@Xfce"
        state: "present"
        enablerepo: "epel"

huangapple
  • 本文由 发表于 2020年1月3日 22:03:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/59579917.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定