Skip to content

Provide a non-JSON method of specifying extension requests and certificate attributes at the command line #82

@jessereynolds

Description

@jessereynolds

Escaping JSON correctly in a bash script is a bit of a nightmare. There's probably a more elegant way than what I have done but if there is I don't believe it is going to be easy for people to work out.

My use case for this is the need to hand my customer an easy to understand, straightforward shell script that shows how to drive the bootstrap task and is itself executable for this task. The following is what I have come up with, which seems overly convoluted:

#!/bin/bash

datacenter="ADL"
is_greenfields="true"
provisioner="bolt"
server="puppet.example.com"
autosign_token="changeme"

# JSON FTW (and all the quoting and escaping)
extension_requests="[\"pp_datacenter=${datacenter}\", \"pp_provisioner=${provisioner}\", \"1.3.6.1.4.1.34380.1.2.1=${is_greenfields}\"]"
custom_attributes="[\"challengePassword=${autosign_token}\"]"

# reads a nodes.txt file containing a list of machine URIs to install the agent onto
command="bolt task run bootstrap --nodes @nodes.txt \
  master=${server} \
  'extension_request=${extension_requests}' \
  'custom_attribute=${custom_attributes}'"

# execute the command in a new bash shell so quoting of arguments are properly dealt with
bash -c "${command}"

So, I think we should have a way of specifying multiple extension requests, and custom attributes, on the command line that does not require encapsulation of JSON.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions