mayn / packerlicious

use python to make hashicorp packer templates
Apache License 2.0
103 stars 51 forks source link

Add support for `ssh_clear_authorized_keys` #158

Closed Cbeck527 closed 6 years ago

Cbeck527 commented 6 years ago

Happy Hacktoberfest! 🎃

Issue

https://github.com/mayn/packerlicious/issues/156

List of Changes Proposed

Add support for ssh_clear_authorized_keys

Testing Evidence

In [1]: from packerlicious import builder, provisioner, Template

In [2]: template = Template()

In [3]: template.add_builder(
   ...:         builder.AmazonEbs(
   ...:           access_key="...",
   ...:           secret_key="...",
   ...:           region = "us-east-1",
   ...:           source_ami="ami-fce3c696",
   ...:           instance_type="t2.micro",
   ...:           ssh_username="ubuntu",
   ...:           ami_name="packer {{timestamp}}",
   ...:           communicator="ssh",
   ...:           ssh_clear_authorized_keys=True))
Out[3]: <packerlicious.builder.AmazonEbs at 0x10e940ac8>

In [4]: print(template.to_json())
{
  "builders": [
    {
      "access_key": "...",
      "ami_name": "packer {{timestamp}}",
      "communicator": "ssh",
      "instance_type": "t2.micro",
      "region": "us-east-1",
      "secret_key": "...",
      "source_ami": "ami-fce3c696",
      "ssh_clear_authorized_keys": "true",
      "ssh_username": "ubuntu",
      "type": "amazon-ebs"
    }
  ]
}

packer also validates this template:

$ cat test.json
{
  "builders": [
    {
      "access_key": "...",
      "ami_name": "packer {{timestamp}}",
      "communicator": "ssh",
      "instance_type": "t2.micro",
      "region": "us-east-1",
      "secret_key": "...",
      "source_ami": "ami-fce3c696",
      "ssh_clear_authorized_keys": "true",
      "ssh_username": "ubuntu",
      "type": "amazon-ebs"
    }
  ]
}

$ packer version
Packer v1.3.1

$ packer validate test.json
Template validated successfully.
coveralls commented 6 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 5e7fd524f480d5cafe955fbb77a5f19c2d023b94 on Cbeck527:master into 56a30a1879d2603315568928379aebc411c5099f on mayn:master.

mayn commented 6 years ago

@Cbeck527, thanks!