One guess would be that cloud-init might do this.
On Wed, Aug 14, 2019, 19:19 Stephen Schlie <[email protected]> wrote:
> Hi Folks,
>
> I've run into an issue recently with packer where my output vagrant box
> has password based ssh disabled by default, even when I explicitly enable
> it in the last provisioner step. I'll include the template json below but
> in short we build an ubuntu 18.04.3 image with the virtualbox-iso builder,
> run a couple of scripts to setup things, and output the box.
>
> This was working until recently, I went and updated our setup to start
> building amis too, and the vagrant VMs stopped working. I tried rolling
> most of it back to see if it helped but I am still seeing this issue.
>
> template:
>
> "_comment": "This file managed by salt. Local changes will be
> overwritten.",
> "builders": [
> {
> "vm_name": "{{user `vmname`}}",
> "type": "virtualbox-iso",
> "headless": true,
> "vrdp_bind_address": "0.0.0.0",
> "guest_os_type": "Ubuntu_64",
> "iso_url": "http://{{user `webserver`}}/{{user `os_file`}}.iso",
> "iso_checksum_url": "{{user `iso_checksum`}}",
> "iso_checksum_type": "file",
> "ssh_username": "packer",
> "ssh_password": "packer",
> "ssh_wait_timeout": "15m",
> "shutdown_command": "echo 'packer' | sudo -S shutdown -P now",
> "disk_size": "30000",
> "hard_drive_interface": "sata",
> "vboxmanage": [
> [
> "modifyvm",
> "{{.Name}}",
> "--boot1",
> "dvd"
> ],
> [
> "modifyvm",
> "{{.Name}}",
> "--boot2",
> "disk"
> ],
> [
> "modifyvm",
> "{{.Name}}",
> "--nictype1",
> "virtio"
> ],
> [
> "modifyvm",
> "{{.Name}}",
> "--memory",
> "2048"
> ],
> [
> "modifyvm",
> "{{.Name}}",
> "--cpus",
> "4"
> ],
> [
> "modifyvm",
> "{{.Name}}",
> "--audio",
> "none"
> ],
> [
> "modifyvm",
> "{{.Name}}",
> "--usb",
> "off"
> ]
> ],
> "boot_command": [
> "<esc><esc><enter><wait>",
> "/install/vmlinuz noapic ",
> "preseed/url=http://{{user `webserver`}}/{{user `os_file`}}.cfg ",
> "debian-installer=en_US auto locale=en_US kbd-chooser/method=us ",
> "hostname={{user `vmname`}} ",
> "fb=false debconf/frontend=noninteractive ",
> "keyboard-configuration/modelcode=SKIP
> keyboard-configuration/layout=USA ",
> "keyboard-configuration/variant=USA
> console-setup/ask_detect=false ",
> "DEBCONF=debug ",
> "initrd=/install/initrd.gz -- <enter>"
> ],
> "output_directory": "vbox/"
> },
> {
> "type": "amazon-ebs",
> "access_key": "{{ user `access_key` }}",
> "secret_key": "{{ user `secret_key` }}",
> "ami_users": [
> "<snip>",
> "<snip>"
> ],
> "region": "us-east-1",
> "source_ami_filter": {
> "filters": {
> "name":
> "ubuntu/images/hvm-ssd/*ubuntu-bionic-18.04-amd64-server-*",
> "root-device-type": "ebs"
> },
> "owners": ["099720109477"],
> "most_recent": true
> },
> "vpc_id": "vpc-04ee3040de35bc755",
> "subnet_id": "subnet-05b0e1ad8679eb394",
> "instance_type": "t3.micro",
> "ssh_username": "ubuntu",
> "ami_name": "{{user `vmname`}}-{{user `salt_environment`}}-{{ user
> `commit` }}",
> "spot_price": "0.0104",
> "run_tags": {
> "application": "packer"
> }
> }
> ],
> "provisioners": [
> {
> "type": "file",
> "source": "upload/",
> "destination": "/tmp"
> },
> {
> "type": "shell",
> "inline": [
> "/usr/bin/cloud-init status --wait"
> ],
> "only": ["amazon-ebs"]
> },
> {
> "type": "shell",
> "scripts": [
> "/etc/vmimage/init.sh"
> ],
> "environment_vars": [
> "SALT_ENVIRONMENT={{user `salt_environment`}}",
> "SALT_VERSION={{user `salt_version`}}",
> "SLS_STATES={{user `sls_states`}}"
> ]
> },
> {
> "type": "shell",
> "inline": [
> "sudo mount /home/packer/VBoxGuestAdditions.iso /mnt",
> "sudo sh /mnt/VBoxLinuxAdditions.run || true",
> "sudo umount /mnt",
> "sudo dmidecode -s system-product-name > /home/packer/vmtype"
> ],
> "only": ["virtualbox-iso"]
> },
> {
> "type": "shell",
> "inline": [
> "sudo sed -i 's/^PasswordAuthentication no/PasswordAuthentication
> yes/' /etc/ssh/sshd_config",
> "sudo cat /etc/ssh/sshd_config"
> ],
> "only": ["virtualbox-iso"]
> }
> ],
> "post-processors": [
> {
> "type": "vagrant",
> "output": "plos_{{.Provider}}_{{user `commit`}}_{{isotime
> \"2006-01-02-150405\"}}.box",
> "keep_input_artifact": true,
> "only": ["virtualbox-iso"]
> }
> ]
> }
>
> The init.sh script just installs some packages and sets up salt to run.
> Then the final step is to flip that sshd config setting so we can login the
> first time to set things up in Vagrant. You can see I was cat'ing out the
> file to be sure it was getting changed, and it is, but when I fire up my
> box in vagrant, it is set back to "no" thus preventing our first login with
> packer/packer to do our initial provisioning.
>
> I'm open to changing up how we do things, but am lost as to why my
> sshd_config changes are being reset?
>
> --
> This mailing list is governed under the HashiCorp Community Guidelines -
> https://www.hashicorp.com/community-guidelines.html. Behavior in
> violation of those guidelines may result in your removal from this mailing
> list.
>
> GitHub Issues: https://github.com/mitchellh/packer/issues
> IRC: #packer-tool on Freenode
> ---
> You received this message because you are subscribed to the Google Groups
> "Packer" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/packer-tool/cb78b72f-daa7-40e3-8760-f251338b0110%40googlegroups.com
> <https://groups.google.com/d/msgid/packer-tool/cb78b72f-daa7-40e3-8760-f251338b0110%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
--
This mailing list is governed under the HashiCorp Community Guidelines -
https://www.hashicorp.com/community-guidelines.html. Behavior in violation of
those guidelines may result in your removal from this mailing list.
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups
"Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/packer-tool/CALz9Rt9E__7YFJRrmLt7vhahmpBWYJ%3DBcQfHaNYmrxP5OQKyGw%40mail.gmail.com.