Last active
September 4, 2015 00:41
-
-
Save israelshirk/e55613a1607d49856762 to your computer and use it in GitHub Desktop.
Packer race condition due to extra disks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # RHEL 6.7 | |
| install | |
| zerombr | |
| clearpart --all --initlabel | |
| cdrom | |
| lang en_US.UTF-8 | |
| keyboard 'us' | |
| key dcc2e57bdcc6e4e5 | |
| rootpw --iscrypted $sadfasdfasdf --lock | |
| network --onboot yes --device eth0 --bootproto dhcp --noipv6 --hostname=localhost.localdomain | |
| timezone --utc UTC | |
| firewall --enabled --trust eth0 --ssh | |
| authconfig --enableshadow --passalgo=sha512 | |
| selinux --permissive | |
| timezone --utc UTC | |
| skipx | |
| part / --fstype ext4 --size=8096 --grow --asprimary --ondrive=sda | |
| bootloader --location=mbr --append="norhgb net.ifnames=0 biosdevname=0" | |
| firstboot --disabled | |
| services --enabled network,sshd | |
| reboot | |
| %packages --excludedocs | |
| @core | |
| rsyslog | |
| @base | |
| %post | |
| /usr/sbin/groupadd -g 501 vagrant | |
| /usr/sbin/useradd -u 501 -g 501 -m vagrant | |
| echo "vagrant"|passwd --stdin vagrant | |
| echo 'Defaults:vagrant !requiretty' >> /etc/sudoers.d/vagrant | |
| echo '%vagrant ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers.d/vagrant | |
| mkdir /home/vagrant/.ssh | |
| cat <<THE_END > /home/vagrant/.ssh/authorized_keys | |
| ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key | |
| THE_END | |
| chown vagrant:vagrant -R /home/vagrant/.ssh | |
| chmod 700 /home/vagrant/.ssh | |
| chmod 600 /home/vagrant/.ssh/authorized_keys | |
| chcon -R unconfined_u:object_r:user_home_t:s0 /home/vagrant/.ssh | |
| echo > /etc/udev/rules.d/70-persistent-net.rules | |
| echo > /etc/udev/rules.d/75-persistent-net-generator.rules | |
| sed -i'' -e '/UUID=/d' /etc/sysconfig/network-scripts/ifcfg-eth0 | |
| sed -i'' -e '/HWADDR=/d' /etc/sysconfig/network-scripts/ifcfg-eth0 | |
| sed -i'' -e '/DHCP_HOSTNAME=/d' /etc/sysconfig/network-scripts/ifcfg-eth0 | |
| sed -i'' -e 's/NM_CONTROLLED=.*/NM_CONTROLLED="no"/' /etc/sysconfig/network-scripts/ifcfg-eth0 | |
| %end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/builder/vmware/common/step_configure_vmx.go b/builder/vmware/common/step_configure_vmx.go | |
| index 401d530..da71fe7 100755 | |
| --- a/builder/vmware/common/step_configure_vmx.go | |
| +++ b/builder/vmware/common/step_configure_vmx.go | |
| @@ -25,6 +25,8 @@ func (s *StepConfigureVMX) Run(state multistep.StateBag) multistep.StepAction { | |
| ui := state.Get("ui").(packer.Ui) | |
| vmxPath := state.Get("vmx_path").(string) | |
| +ui.Error("In stepConfigureVMX") | |
| + | |
| vmxContents, err := ioutil.ReadFile(vmxPath) | |
| if err != nil { | |
| err := fmt.Errorf("Error reading VMX file: %s", err) | |
| @@ -52,7 +54,7 @@ func (s *StepConfigureVMX) Run(state multistep.StateBag) multistep.StepAction { | |
| // Set custom data | |
| for k, v := range s.CustomData { | |
| - log.Printf("Setting VMX: '%s' = '%s'", k, v) | |
| + fmt.Printf("Setting VMX: '%s' = '%s'", k, v) | |
| k = strings.ToLower(k) | |
| vmxData[k] = v | |
| } | |
| diff --git a/builder/vmware/common/vmx.go b/builder/vmware/common/vmx.go | |
| index e7cdb66..3b652c1 100755 | |
| --- a/builder/vmware/common/vmx.go | |
| +++ b/builder/vmware/common/vmx.go | |
| @@ -17,6 +17,8 @@ import ( | |
| func ParseVMX(contents string) map[string]string { | |
| results := make(map[string]string) | |
| +fmt.Fprintf(os.Stderr, "In ParseVMX") | |
| + | |
| lineRe := regexp.MustCompile(`^(.+?)\s*=\s*"(.*?)"\s*$`) | |
| for _, line := range strings.Split(contents, "\n") { | |
| @@ -27,6 +29,8 @@ func ParseVMX(contents string) map[string]string { | |
| key := strings.ToLower(matches[1]) | |
| results[key] = matches[2] | |
| + | |
| + fmt.Fprintf(os.Stderr, "read from vmx: %s = %s\n", key, results[key]) | |
| } | |
| return results | |
| @@ -36,6 +40,8 @@ func ParseVMX(contents string) map[string]string { | |
| func EncodeVMX(contents map[string]string) string { | |
| var buf bytes.Buffer | |
| +fmt.Fprintf(os.Stderr, "In EncodeVMX") | |
| + | |
| i := 0 | |
| keys := make([]string, len(contents)) | |
| for k, _ := range contents { | |
| @@ -45,6 +51,8 @@ func EncodeVMX(contents map[string]string) string { | |
| sort.Strings(keys) | |
| for _, k := range keys { | |
| + fmt.Fprintf(os.Stderr, "writing to buffer: %s = %s\n", k, contents[k]) | |
| + | |
| buf.WriteString(fmt.Sprintf("%s = \"%s\"\n", k, contents[k])) | |
| } | |
| @@ -54,9 +62,14 @@ func EncodeVMX(contents map[string]string) string { | |
| // WriteVMX takes a path to a VMX file and contents in the form of a | |
| // map and writes it out. | |
| func WriteVMX(path string, data map[string]string) (err error) { | |
| + | |
| +fmt.Fprintf(os.Stderr, "In ParseVMX") | |
| + | |
| log.Printf("Writing VMX to: %s", path) | |
| f, err := os.Create(path) | |
| if err != nil { | |
| +fmt.Fprintf(os.Stderr, "Failed in writeVMX because %s", err) | |
| + | |
| return | |
| } | |
| defer f.Close() | |
| @@ -64,9 +77,12 @@ func WriteVMX(path string, data map[string]string) (err error) { | |
| var buf bytes.Buffer | |
| buf.WriteString(EncodeVMX(data)) | |
| if _, err = io.Copy(f, &buf); err != nil { | |
| +fmt.Fprintf(os.Stderr, "Writing to file failed") | |
| return | |
| } | |
| +fmt.Fprintf(os.Stderr, "Wroted to file") | |
| + | |
| return | |
| } | |
| @@ -77,5 +93,7 @@ func ReadVMX(path string) (map[string]string, error) { | |
| return nil, err | |
| } | |
| + fmt.Fprintf(os.Stderr, "Read VMX data: %s", data) | |
| + | |
| return ParseVMX(string(data)), nil | |
| } | |
| diff --git a/version.go b/version.go | |
| index 860971e..a324428 100644 | |
| --- a/version.go | |
| +++ b/version.go | |
| @@ -9,4 +9,4 @@ const Version = "0.8.6" | |
| // A pre-release marker for the version. If this is "" (empty string) | |
| // then it means that it is a final release. Otherwise, this is a pre-release | |
| // such as "dev" (in development), "beta", "rc1", etc. | |
| -const VersionPrerelease = "" | |
| +const VersionPrerelease = "dev" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "builders": [ | |
| { | |
| "boot_command": "<tab> text ks=floppy<enter><wait>", | |
| "boot_wait": "5s", | |
| "disk_additional_size": [ | |
| "{{ user `disk_common` }}", | |
| "{{ user `disk_log` }}", | |
| "{{ user `disk_tmp` }}", | |
| "{{ user `disk_search` }}" | |
| ], | |
| "disk_size": "{{ user `disk_boot` }}", | |
| "disk_type_id": "0", | |
| "floppy_files": [ | |
| "kickstarts/rhel-6.7-min/ks.cfg" | |
| ], | |
| "guest_os_type": "rhel6-64", | |
| "headless": "false", | |
| "iso_checksum": "0e0acb2a544f4d58f10292144161f40439734c6e98b13ba8c595372b20354bc5", | |
| "iso_checksum_type": "none", | |
| "iso_url": "{{ user `iso_root` }}/rhel-server-6.7-x86_64-dvd.iso", | |
| "name": "rhel6-vmware-base", | |
| "output_directory": "rhel6-vmware-base", | |
| "shutdown_command": "echo 'vagrant' | sudo -S /sbin/shutdown -h now", | |
| "ssh_password": "vagrant", | |
| "ssh_username": "vagrant", | |
| "ssh_wait_timeout": "1000s", | |
| "tools_upload_flavor": "linux", | |
| "tools_upload_path": "/home/vagrant/linux.iso", | |
| "type": "vmware-iso", | |
| "vm_name": "rhel6-vmware-base", | |
| "vmdk_name": "disk", | |
| "vmx_data": { | |
| "memsize": "8192", | |
| "numvcpus": "4" | |
| } | |
| } | |
| ], | |
| "provisioners": [], | |
| "variables": { | |
| "disk_boot": "10256", | |
| "disk_common": "57000", | |
| "disk_log": "21000", | |
| "disk_search": "100000", | |
| "disk_tmp": "31000", | |
| "iso_root": "iso", | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "builders": [ | |
| { | |
| "boot_command": "<tab> text ks=floppy<enter><wait>", | |
| "boot_wait": "5s", | |
| "disk_size": "{{ user `disk_boot` }}", | |
| "disk_type_id": "0", | |
| "floppy_files": [ | |
| "kickstarts/rhel-6.7-min/ks.cfg" | |
| ], | |
| "guest_os_type": "rhel6-64", | |
| "headless": "false", | |
| "iso_checksum": "0e0acb2a544f4d58f10292144161f40439734c6e98b13ba8c595372b20354bc5", | |
| "iso_checksum_type": "none", | |
| "iso_url": "{{ user `iso_root` }}/rhel-server-6.7-x86_64-dvd.iso", | |
| "name": "rhel6-vmware-base", | |
| "output_directory": "rhel6-vmware-base", | |
| "shutdown_command": "echo 'vagrant' | sudo -S /sbin/shutdown -h now", | |
| "ssh_password": "vagrant", | |
| "ssh_username": "vagrant", | |
| "ssh_wait_timeout": "1000s", | |
| "tools_upload_flavor": "linux", | |
| "tools_upload_path": "/home/vagrant/linux.iso", | |
| "type": "vmware-iso", | |
| "vm_name": "rhel6-vmware-base", | |
| "vmdk_name": "disk", | |
| "vmx_data": { | |
| "memsize": "8192", | |
| "numvcpus": "4" | |
| } | |
| } | |
| ], | |
| "provisioners": [], | |
| "variables": { | |
| "disk_boot": "10256", | |
| "disk_common": "57000", | |
| "disk_log": "21000", | |
| "disk_search": "100000", | |
| "disk_tmp": "31000", | |
| "iso_root": "iso", | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
("wroted" because "wrote" or "has written" just sounds weird when you're used to talking to 2-year-olds)