cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1962
Views
0
Helpful
1
Replies

CSR: Using ios-config bootstrap property inside cloudformation template

gcote
Level 1
Level 1

I'm using an AWS CloudFormation template to launch a CSR 1000 instance. I'd like to use the "UserData" property to define a new user id. The deployment guide provides an example of how to do this. If I launch the instance from the AWS console, and include the ios-config instruction in the UserData field, it works just fine. I can't seem to get it to work from a CloudFormation template, however.

 

Here's the snippet from my template. Note that I've escaped the double-quote characters because the command is being passed as a string to the Fn::Join function. 

 

"UserData": { "Fn::Base64" : { "Fn::Join" : ["", [
         "hostname=\"csr1k2\"",
          "ios-config-1=\"username cisco priv 15 pass ciscoxyz\""
]]}},

 

When I launch the instance from the template, the instance launches fine. I can ping the interface, but I can't login. It doesn't appear to be an authentication error because get a "connection refused" error, which indicates that the SSH server isn't up.

 

ssh: connect to host 10.0.0.5 port 22: Connection refused

 

This post suggested inserting a newline character. So, I tried that as follows ...

 

 

"UserData": { "Fn::Base64" : { "Fn::Join" : ["", [
     "hostname=\"csr1k2\"",
     "ios-config-1=\"username cisco priv 15 pass ciscoxyz\"\n"
]]}},

 

 

...  but got the same result. I've tried every other combination of quotes, double-quotes, newline characters (e.g. before  & after the escaped quotes) that I can think of. I get the same result regardless.

 

This post suggested using XML-style characters, but I think that only pertains to if I'm embedding the quotes into the IOS command itself.

 

Anyway ... I'm stumped. but not for lack of trying. Again, it works if I launch the instance from the AWS console, so it has to be something with how the string is being based through the CF template. Has anyone been able to get this to work?

 

1 Accepted Solution

Accepted Solutions

gcote
Level 1
Level 1

Sorry to reply to my own post, but I figured it out shortly after :)

 

The solution was to insert newlines. I had *thought* the newlines were only needed for the "ios-config" statements (i.e. that they needed to be passed through to the IOS parser on the router). That wasn't the case. I also needed to add a newline to the "hostname" statement that came before the "ios-config" statement (because the newlines were needed to break up the statements within the CF template processor, or whatever).

 

So, here's what worked ...

 

"UserData": { "Fn::Base64" : { "Fn::Join" : ["", [
     "hostname=\"csr1k2\"\n",
     "ios-config-1=\"username cisco priv 15 pass ciscoxyz\"\n"
]]}},

View solution in original post

1 Reply 1

gcote
Level 1
Level 1

Sorry to reply to my own post, but I figured it out shortly after :)

 

The solution was to insert newlines. I had *thought* the newlines were only needed for the "ios-config" statements (i.e. that they needed to be passed through to the IOS parser on the router). That wasn't the case. I also needed to add a newline to the "hostname" statement that came before the "ios-config" statement (because the newlines were needed to break up the statements within the CF template processor, or whatever).

 

So, here's what worked ...

 

"UserData": { "Fn::Base64" : { "Fn::Join" : ["", [
     "hostname=\"csr1k2\"\n",
     "ios-config-1=\"username cisco priv 15 pass ciscoxyz\"\n"
]]}},
Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: