英文:
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"
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论