geerlingguy / ansible-role-ntp

Ansible Role - NTP
https://galaxy.ansible.com/geerlingguy/ntp/
MIT License
319 stars 243 forks source link

Error running after restoring a VM snapshot #67

Closed jasonpau closed 4 years ago

jasonpau commented 5 years ago

Not sure if it's just me or what, but after restoring a VirtualBox VM snapshot, I get the following error when trying to run my Ansible playbook:

TASK [geerlingguy.ntp : Ensure NTP-related packages are installed.] *********************************************************************************************
 [WARNING]: Updating cache and auto-installing missing dependency: python-apt

fatal: [virtualbox]: FAILED! => {"changed": false, "cmd": "apt-get update", "msg": "E: Release file for http://us.archive.ubuntu.com/ubuntu/dists/bionic-updates/InRelease is not valid yet (invalid for another 46d 2h 17min 1s). Updates for this repository will not be applied...

This fatal error seems to be due to the VM system clock being out of date (since it's the exact time when the snapshot was originally made). Syncing the system clock on the VM resolves this issue. However, it seems strange to have to do that manually, since this role is supposed to handle clock syncing.

Later I realized installing python-apt on the restored snapshot before running my Ansible playbook resolves the issue; geerlingguy.ntp and the rest of the roles in my playbook run successfully.

I'm pretty new to Ansible (and VMs in general), so my apologies if this is a stupid question/issue.

stale[bot] commented 4 years ago

This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!

Please read this blog post to see the reasons why I mark issues as stale.

geerlingguy commented 4 years ago

Not a stupid question; however you typically shouldn't run into this issue with VMs. One thing to try is seeing if the tinker option helps (https://github.com/geerlingguy/ansible-role-ntp/pull/65), probably won't, because that config isn't applied until this role finishes running, which doesn't happen since apt-get update fails.

But it's not something this role can really fix—because if apt-get update itself fails, something needs to be fixed prior to it running.

Note that my VMs that I run through Vagrant (built with Packer) like geerlingguy/ubuntu1804 don't seem to have this issue. Maybe it's a problem caused by the way the snapshots are being created?

Regardless, I think it would be best to look into it on another level—unfortunately, I don't see a way this role can prevent issues with apt-get commands.