boxcutter / centos

Virtual machine templates for CentOS written in legacy JSON
Apache License 2.0
425 stars 198 forks source link

Puppet 4 and line-endings on Windows #42

Closed benpriestman closed 8 years ago

benpriestman commented 8 years ago

This PR attempts to resolve the same problems as two existing, but unaccepted PRs: https://github.com/boxcutter/centos/pull/20 and https://github.com/boxcutter/centos/pull/28.

https://github.com/boxcutter/centos/pull/20 is about the introduction of a new package naming versiong scheme for the official Puppet packages with version 4 of the Puppet language. See https://docs.puppet.com/puppet/latest/reference/about_agent.html for details. That PR introduces a new type CM_VERSION to handle this. This PR uses logic within the script to translate puppet versions to puppet-agent versions. This should be more transparent, but will require updating each time a new release of the puppet-agent packages comes out. We have got the option of simply specifying '4' as the version of Puppet to install to get the latest 4.y.z version, however.

https://github.com/boxcutter/centos/pull/28 relates to problems with sudo when running packer on Windows. Although the error message given refers to needing a tty, the root cause of this appears to be to do with line endings in the files checked out on Windows. By default, git has core.autocrlf=true on Windows. When these files are then used by a Linux VM - particularly anything to do with sudo, bad things happen. The ks7.cfg kickstart script should remove the requirement to have a tty from /etc/sudoers, but this fails when the .cfg file has Windows-style line-endings in it. Using a .gitattributes file to force LF line-endings on relevant files fixes this.

annawake commented 8 years ago

Line endings when building on Windows should be addressed by https://github.com/boxcutter/centos/commit/1a345080ada2af40e341565393fec70b6768cf2c

We're going to phase out the cmtool scripts - we never build them officially or publish them to atlas, so they are not being properly vetted anyway. Instead we'll be using custom-script.sh as the hook for actions like this, similar to what is being done in the ubuntu boxes.