ansible-for-devops icon indicating copy to clipboard operation
ansible-for-devops copied to clipboard

Vagrant up and provisioning failing

Open nitinsinghit opened this issue 2 years ago • 7 comments

I am following chapter 2 and the playbook is resulting in an error

- hosts: all
  become: yes
  tasks:
  - dnf: name=chrony state=present
  - service: name=chronyd state=started enabled=ye
```s

PLAY [all] *********************************************************************

TASK [Gathering Facts] ********************************************************* ok: [default] [DEPRECATION WARNING]: Distribution centos 8.7 on host default should use /usr/libexec/platform-python, but is using /usr/bin/python for backward compatibility with prior Ansible releases. A future Ansible release will default to using the discovered platform python for this host. See https://docs .ansible.com/ansible/2.10/reference_appendices/interpreter_discovery.html for more information. This feature will be removed in version 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.

TASK [dnf] ********************************************************************* fatal: [default]: FAILED! => {"changed": false, "msg": "Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: Curl error (60): Peer certificate cannot be authenticated with given CA certificates for https://mirrors.rockylinux.org/mirrorlist?arch=x86_64&repo=AppStream-8 [SSL certificate problem: self signed certificate in certificate chain]", "rc": 1, "results": []}

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

Ansible failed to complete successfully. Any error output should be visible above. Please fix these errors and try again.

I am using iMac os version Monterey 12.6.2. Also I had to execute this line `vagrant box add geerlingguy/rockylinux8 --insecure` before `vagrant provision` 

Please guide.

Regards,
Nitin

nitinsinghit avatar Jan 17 '23 20:01 nitinsinghit

I'm having the same issue, this makes the book unsuitable for learning Ansible.

sergefonville avatar Dec 30 '23 15:12 sergefonville

Can you please provide which exact playbook you're running into this error on? I thought I had converted all examples from broken CentOS/Red Hat to the working Rocky Linux versions... but I may have missed one or two.

geerlingguy avatar Jan 01 '24 16:01 geerlingguy

Edit: After some rereading of the issue, mine seems completely different...

It seems to fail at vagrant provision

I am attempting it on Windows, these are the steps with their output: vagrant box add geerlingguy/rockylinux8

==> box: Loading metadata for box 'geerlingguy/rockylinux8'
	box: URL: https://vagrantcloud.com/api/v2/vagrant/geerlingguy/rockylinux8
==> box: Adding box 'geerlingguy/rockylinux8' (v1.0.1) for provider: virtualbox
	box: Downloading: https://vagrantcloud.com/geerlingguy/boxes/rockylinux8/versions/1.0.1/providers/virtualbox/unknown/vagrant.box
	box:
==> box: Successfully added box 'geerlingguy/rockylinux8' (v1.0.1) for 'virtualbox'!

vagrant init geerlingguy/rockylinux8

A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.

vagrant up

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'geerlingguy/rockylinux8'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'geerlingguy/rockylinux8' version '1.0.1' is up to date...
==> default: Setting the name of the VM: geerlingguy_default_1704129670229_97512
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default:
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default:
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: The guest additions on this VM do not match the installed version of
    default: VirtualBox! In most cases this is fine, but in rare cases it can
    default: prevent things such as shared folders from working properly. If you see
    default: shared folder errors, please make sure the guest additions within the
    default: virtual machine match the version of VirtualBox you have installed on
    default: your host and reload your VM.
    default:
    default: Guest Additions Version: 6.1.32
    default: VirtualBox Version: 7.0
==> default: Mounting shared folders...
    default: /vagrant => %cd%

Update the Vagrantfile

# Provisioning configuration for Ansible.
config.vm.provision "ansible" do |ansible|
  ansible.playbook = "playbook.yml"
end

Create playbook.yml

---
- hosts: all
  become: yes

tasks:
  - name: Ensure chrony (for time synchronization) is installed.
    dnf:
      name: chrony
      state: present

  - name: Ensure chrony is running.
    service:
      name: chronyd
      state: started
      enabled: yes

vagrant provision

==> default: Running provisioner: ansible...
Windows is not officially supported for the Ansible Control Machine.
Please check https://docs.ansible.com/intro_installation.html#control-machine-requirements
Vagrant gathered an unknown Ansible version:

and falls back on the compatibility mode '1.8'.

Alternatively, the compatibility mode can be specified in your Vagrantfile:
https://www.vagrantup.com/docs/provisioning/ansible_common.html#compatibility_mode
    default: Running ansible-playbook...
The Ansible software could not be found! Please verify
that Ansible is correctly installed on your host system.

If you haven't installed Ansible yet, please install Ansible
on your host system. Vagrant can't do this for you in a safe and
automated way.
Please check https://docs.ansible.com for more information.

sergefonville avatar Jan 01 '24 17:01 sergefonville

I've just started working my way through the book and came here to report this same issue. I'm using a Windows host and trying to run Vagrant/Ansible from PowerShell. It seems it's not supported so perhaps you can update your text to highlight this.

Are there any options for using Ansible on Windows or should we just be using Linux hosts?

Edit: the issue I'm referring to is the Windows is not officially supported for the Ansible Control Machine.

shareefj avatar Jan 11 '24 16:01 shareefj

@shareefj Windows has never been able to be used as an Ansible control machine and that's not likely to ever change. You can, however, use WSL with Linux to run Ansible. See https://docs.ansible.com/archive/ansible/2.5/user_guide/windows_faq.html

rclilly avatar Jan 11 '24 17:01 rclilly

@shareefj Windows has never been able to be used as an Ansible control machine and that's not likely to ever change. You can, however, use WSL with Linux to run Ansible. See https://docs.ansible.com/archive/ansible/2.5/user_guide/windows_faq.html

I installed Vagrant and VirtualBox under my windows OS. Do I need to uninstall them from windows and then install them as part of the WSL? I want to learn ansible, but at the same time I don't want to convert everything over to Linux.

catanbri avatar Mar 03 '24 02:03 catanbri

I installed Vagrant and VirtualBox under my windows OS. Do I need to uninstall them from windows and then install them as part of the WSL? I want to learn ansible, but at the same time I don't want to convert everything over to Linux.

If you're using Vagrant/VirtualBox then the virtual machine is undoubtedly some version of Linux. That works just fine. Prior to the Windows Subsystem for Linux (WSL) that was the main way to use Ansible on a Windows machine.

rclilly avatar Mar 04 '24 05:03 rclilly