Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chef provisioner not working in FreeBSD #18794

Closed
alice-sawatzky opened this issue Sep 5, 2018 · 2 comments
Closed

Chef provisioner not working in FreeBSD #18794

alice-sawatzky opened this issue Sep 5, 2018 · 2 comments

Comments

@alice-sawatzky
Copy link
Contributor

alice-sawatzky commented Sep 5, 2018

Terraform Version

Terraform v0.11.8
+ provider.aws v1.34.0

Terraform Configuration Files

(this requires a SSH key pair in the same directory, with the file names test and test.pub for the private and public keys, respectively)

provider "aws" {
  region = "ca-central-1"
}

resource "aws_key_pair" "freebsd_test" {
  key_name = "freebsd_test"
  public_key = "${file("test.pub")}"
}

resource "aws_security_group" "freebsd_test" {
  name = "freebsd_ssh"
  ingress {
    from_port = 22
    to_port = 22
    protocol = "TCP"
    cidr_blocks = ["0.0.0.0/0"]
  }

  egress {
    from_port       = 0
    to_port         = 0
    protocol        = "-1"
    cidr_blocks     = ["0.0.0.0/0"]
  }
}

resource "aws_instance" "freebsd_test" {
  ami           = "ami-54a32130" #FreeBSD 11.2
  instance_type = "t2.micro"
  key_name = "${aws_key_pair.freebsd_test.key_name}"
  security_groups = ["freebsd_ssh"]
  #the chef provisioner needs sudo, curl, and bash to work
  provisioner "remote-exec" {
    inline = [
      "echo 'pkg install -y sudo curl bash' | su",
      "echo 'echo \"ec2-user ALL=(ALL) NOPASSWD:ALL\" >> /usr/local/etc/sudoers' | su"
    ]
    connection {
      type = "ssh"
      user = "ec2-user"
      private_key = "${file("test")}"
    }
  }

  provisioner "chef" {
    node_name = "freebsd-test"
    run_list = ["example"]
    server_url = "example.com"
    user_key = "test"
    user_name = "test"
    connection {
      type = "ssh"
      user = "ec2-user"
      private_key = "${file("test")}"
    }
  }
}

Expected Behavior

The dummy chef config should have been created, likely failing on the dummy server URL and credentials given.

Actual Behavior

The provisioner fails when trying to chown the user key, because it uses an outdated syntax for chown that most Linux distros accept as a backwards compatibility measure, but FreeBSD doesn't.

aws_instance.freebsd_test: Still creating... (3m30s elapsed)
aws_instance.freebsd_test (chef): Thank you for installing Chef!
aws_instance.freebsd_test (chef): Creating configuration files...
aws_instance.freebsd_test: Still creating... (3m40s elapsed)
aws_instance.freebsd_test (chef): chown: root.root: illegal user name
aws_instance.freebsd_test (chef): Cleanup user key...

Steps to Reproduce

  1. mkdir freebsd-test; cd freebsd-test
  2. ssh keygen -t rsa -f test
  3. copy the configuration file in this bug report to main.tf
  4. terraform apply

References

PR #18533 fixes this

@svanharmelen
Copy link
Contributor

Closing this issue as PR #18533 is just merged and will be in the next release.

@ghost
Copy link

ghost commented Apr 1, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants