为什么 Vagrant 配置 httpd 失败? “没有可用的 httpd 包。”

问题描述 投票:0回答:1

我的流浪文件

Vagrant.configure("2") do |config|
  config.vm.box = "generic/rhel8"

  config.vm.provision "ansible" do |ansible|
    ansible.compatibility_mode = "auto"
    ansible.playbook = "apache.yml"
    ansible.verbose = "v"
  end
end

apache.yml

---
- name: setup webserver
  hosts: all
  become: true
  tasks:
    - name: httpd installed
      ansible.builtin.yum:
        name: httpd
        update_cache: true
        state: latest
    - name: custom index.html
      ansible.builtin.copy:
        dest: "/var/www/html/index.html"
        content: |
          Custom Web Page
    - name: httpd service enabled
      ansible.builtin.service:
        name: httpd
        enabled: true
        state: started
    - name: open firewall
      ansible.posix.firewalld:
        service: http
        state: enabled
        immediate: true
        permanent: true

当我运行 vagrant Provision 时出现错误

TASK [Gathering Facts] *********************************************************
ok: [default]

TASK [httpd installed] *********************************************************
fatal: [default]: FAILED! => {"changed": false, "failures": ["No package httpd available."], "msg": "Failed to install some of the specified packages", "rc": 1, "results": []}

PLAY RECAP *********************************************************************
default                    : ok=1    changed=0    unreachable=0    failed=1  

红帽8

[vagrant@rhel8 ~]$ uname -a
Linux rhel8.localdomain 4.18.0-513.5.1.el8_9.x86_64 #1 SMP Fri Sep 29 05:21:10 EDT 2023 x86_64 x86_64 x86_64 GNU/Linux

为什么?

ansible vagrant
1个回答
0
投票

我忘记了 RHEL8 订阅。添加后

  tasks:
    - name: Register as user with password and auto-subscribe to available content.
      redhat_subscription:
        state: present
        username: mysuserhadzi
        password: ypass2
        auto_attach: true 

一切正常。

TASK [httpd installed] *********************************************************
changed: [default] => {"changed": true, "msg": "", "rc": 0, "results": ["Installed: redhat-logos-httpd-84.5-2.el8.noarch", "Installed: apr-util-bdb-1.6.1-9.el8.x86_64", "Installed: apr-util-openssl-1.6.1-9.el8.x86_64", "Installed: mailcap-2.1.48-3.el8.noarch", "Installed: mod_http2-1.15.7-8.module+el8.9.0+19080+567b90f8.3.x86_64", "Installed: apr-1.6.3-12.el8.x86_64", "Installed: apr-util-1.6.1-9.el8.x86_64", "Installed: httpd-2.4.37-62.module+el8.9.0+19699+7a7a2044.x86_64", "Installed: httpd-filesystem-2.4.37-62.module+el8.9.0+19699+7a7a2044.noarch", "Installed: httpd-tools-2.4.37-62.module+el8.9.0+19699+7a7a2044.x86_64"]}
© www.soinside.com 2019 - 2024. All rights reserved.