hashicorp / terraform

Terraform enables you to safely and predictably create, change, and improve infrastructure. It is a source-available tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned.
https://www.terraform.io/
Other
42.41k stars 9.5k forks source link

Openstack: Allow for "--file" option to be used for day0-config #4526

Closed aunraza closed 8 years ago

aunraza commented 8 years ago

Openstack nova allows for the use of a file to bootstrap virtual appliances, such as Cisco CSR (Cloud Services Router), using a configuration file. The command to do that is as following:

nova boot < instance_name > --image < image_id > --flavor < flavor_id > --nic net-id= < uuid > --config-drive= < true / false > --file < configuration_file_name >

However, with terraform the --file option does not exist. Can this functionality be added, or is this something that would not work with terraform?

erieddy commented 8 years ago

I too have the same issue with the Cisco Adaptive Security Appliance Virtual (ASAv) Edition. With nova we can run the command nova boot with --config-drive true --file day0=day-0.config ASAv and boot up the ASAv with a specified configuration. Without the File option requested we can't use the config-drive with the ASAv and Terraform. We have to go directly to nova.

jtopjian commented 8 years ago

Would it be possible to provide the output of nova --debug boot when using this flag? That will show what API parameters are being passed to Nova. It would help a lot with expediting this feature or determining if modifications to the underlying OpenStack Go library are required.

Please be careful to sanitize the output! :smile:

aunraza commented 8 years ago

Thanks for the quick response! You can find the output below:

$ nova --debug boot  --flavor Micro-Small --image a85692b5-3a5f-42f9-bbed-cb6832826992 --nic net-id=bd07df1c-632e-4fa4-a7bb-77f7df46abbf --nic net-id=21ade440-3483-4b5f-9de7-2268f7d393da --config-drive true --file day0=day-0.config ASAv-day-0-v5 
DEBUG (session:198) REQ: curl -g -i -X GET https://our-openstack-server.com:5000/v2.0 -H "Accept: application/json" -H "User-Agent: python-keystoneclient"
INFO (connectionpool:735) Starting new HTTPS connection (1): our-openstack-server.com
DEBUG (connectionpool:383) "GET /v2.0 HTTP/1.1" 200 630
DEBUG (session:216) RESP: [200] content-length: 630 via: 1.1 Repose (Repose/7.1.4.0) vary: X-Auth-Token server: Jetty(9.2.z-SNAPSHOT) x-trans-id: 9a1a766c-4434-403b-a369-ab6c9dc4f3af date: Wed, 06 Jan 2016 19:18:32 GMT, Wed, 06 Jan 2016 19:18:32 GMT content-type: application/json 
RESP BODY: {"version": {"status": "stable", "updated": "2014-04-17T00:00:00Z", "media-types": [{"base": "application/json", "type": "application/vnd.openstack.identity-v2.0+json"}, {"base": "application/xml", "type": "application/vnd.openstack.identity-v2.0+xml"}], "id": "v2.0", "links": [{"href": "https://our-openstack-server.com:5000/v2.0/", "rel": "self"}, {"href": "http://docs.openstack.org/api/openstack-identity-service/2.0/content/", "type": "text/html", "rel": "describedby"}, {"href": "http://docs.openstack.org/api/openstack-identity-service/2.0/identity-dev-guide-2.0.pdf", "type": "application/pdf", "rel": "describedby"}]}}

DEBUG (v2:86) Making authentication request to https://our-openstack-server.com:5000/v2.0/tokens
DEBUG (connectionpool:383) "POST /v2.0/tokens HTTP/1.1" 200 6382
DEBUG (session:198) REQ: curl -g -i -X GET https://our-openstack-server.com:8774/v2/ -H "User-Agent: python-novaclient" -H "Accept: application/json" -H "X-Auth-Token: {SHA1}OUR-SHA-KEY"
INFO (connectionpool:735) Starting new HTTPS connection (1): our-openstack-server.com
DEBUG (connectionpool:383) "GET /v2/ HTTP/1.1" 200 646
DEBUG (session:216) RESP: [200] content-length: 646 via: 1.1 Repose (Repose/7.1.4.0) x-compute-request-id: req-127f19a5-9e85-4ca7-b0c6-ae1af1be14fd server: Jetty(9.2.z-SNAPSHOT) x-trans-id: bfa977a5-ef2b-4ed5-9225-6bed97fa4a81 date: Wed, 06 Jan 2016 19:18:33 GMT, Wed, 06 Jan 2016 19:18:33 GMT content-type: application/json 
RESP BODY: {"version": {"status": "CURRENT", "updated": "2011-01-21T11:33:21Z", "media-types": [{"base": "application/xml", "type": "application/vnd.openstack.compute+xml;version=2"}, {"base": "application/json", "type": "application/vnd.openstack.compute+json;version=2"}], "id": "v2.0", "links": [{"href": "http://our-openstack-server.com:8774/v2/", "rel": "self"}, {"href": "http://docs.openstack.org/api/openstack-compute/2/os-compute-devguide-2.pdf", "type": "application/pdf", "rel": "describedby"}, {"href": "http://docs.openstack.org/api/openstack-compute/2/wadl/os-compute-2.wadl", "type": "application/vnd.sun.wadl+xml", "rel": "describedby"}]}}

DEBUG (session:198) REQ: curl -g -i -X GET https://our-openstack-server.com:8774/v2/our-project-id-uid/images/a85692b5-3a5f-42f9-bbed-cb6832826992 -H "User-Agent: python-novaclient" -H "Accept: application/json" -H "X-Auth-Token: {SHA1}OUR-SHA-KEY"
DEBUG (connectionpool:383) "GET /v2/our-project-id-uid/images/a85692b5-3a5f-42f9-bbed-cb6832826992 HTTP/1.1" 200 824
DEBUG (session:216) RESP: [200] content-length: 824 via: 1.1 Repose (Repose/7.1.4.0) x-compute-request-id: req-60cc2b46-9cce-497c-891c-ce9084bb6cdc server: Jetty(9.2.z-SNAPSHOT) x-trans-id: 2e65324f-b5f8-4c2d-8ea9-1b30519e0ed4 date: Wed, 06 Jan 2016 19:18:34 GMT, Wed, 06 Jan 2016 19:18:34 GMT content-type: application/json 
RESP BODY: {"image": {"status": "ACTIVE", "updated": "2016-01-06T16:02:30Z", "links": [{"href": "http://our-openstack-server.com:8774/v2/our-project-id-uid/images/a85692b5-3a5f-42f9-bbed-cb6832826992", "rel": "self"}, {"href": "http://our-openstack-server.com:8774/our-project-id-uid/images/a85692b5-3a5f-42f9-bbed-cb6832826992", "rel": "bookmark"}, {"href": "http://our-openstack-server:9292/our-project-id-uid/images/a85692b5-3a5f-42f9-bbed-cb6832826992", "type": "application/vnd.openstack.image", "rel": "alternate"}], "id": "a85692b5-3a5f-42f9-bbed-cb6832826992", "OS-EXT-IMG-SIZE:size": 169017344, "name": "ASAv-9.5.2-QCOW2", "created": "2016-01-06T14:36:21Z", "minDisk": 0, "progress": 100, "minRam": 0, "metadata": {"os_distro": "Unknown", "os_name": "Unknown", "os_version": "Unknown"}}}

DEBUG (session:198) REQ: curl -g -i -X GET https://our-openstack-server.com:8774/v2/our-project-id-uid/flavors/Micro-Small -H "User-Agent: python-novaclient" -H "Accept: application/json" -H "X-Auth-Token: {SHA1}OUR-SHA-KEY"
DEBUG (connectionpool:383) "GET /v2/our-project-id-uid/flavors/Micro-Small HTTP/1.1" 404 78
DEBUG (session:216) RESP: [404] content-length: 78 via: 1.1 Repose (Repose/7.1.4.0) x-compute-request-id: req-39acd440-8aed-4b4a-94c0-ac62e075d71e server: Jetty(9.2.z-SNAPSHOT) x-trans-id: e4e26bb6-1315-432b-a305-d18e034a7885 date: Wed, 06 Jan 2016 19:18:35 GMT, Wed, 06 Jan 2016 19:18:35 GMT content-type: application/json; charset=UTF-8 
RESP BODY: {"itemNotFound": {"message": "The resource could not be found.", "code": 404}}

DEBUG (session:198) REQ: curl -g -i -X GET https://our-openstack-server.com:8774/v2/our-project-id-uid/flavors?is_public=None -H "User-Agent: python-novaclient" -H "Accept: application/json" -H "X-Auth-Token: {SHA1}OUR-SHA-KEY"
DEBUG (connectionpool:383) "GET /v2/our-project-id-uid/flavors?is_public=None HTTP/1.1" 200 11747
DEBUG (session:216) RESP: [200] content-length: 11747 via: 1.1 Repose (Repose/7.1.4.0) x-compute-request-id: req-3bc7d472-d8de-4026-8eb5-303a351fab72 server: Jetty(9.2.z-SNAPSHOT) x-trans-id: 39288e5e-8a6c-4de3-8be6-e460991391e0 date: Wed, 06 Jan 2016 19:18:35 GMT, Wed, 06 Jan 2016 19:18:36 GMT content-type: application/json 
RESP BODY: {"flavors": [{"id": "0cbe318b-a6a1-4c3d-9d36-2dfbd042a024", "links": [{"href": "http://our-openstack-server.com:8774/v2/our-project-id-uid/flavors/0cbe318b-a6a1-4c3d-9d36-2dfbd042a024", "rel": "self"}, {"href": "http://our-openstack-server.com:8774/our-project-id-uid/flavors/0cbe318b-a6a1-4c3d-9d36-2dfbd042a024", "rel": "bookmark"}], "name": "HS2-FullSize"}, {"id": "11c7ed55-6f26-41e9-9228-df38df07441b", "links": [{"href": "http://our-openstack-server.com:8774/v2/our-project-id-uid/flavors/11c7ed55-6f26-41e9-9228-df38df07441b", "rel": "self"}, {"href": "http://our-openstack-server.com:8774/our-project-id-uid/flavors/11c7ed55-6f26-41e9-9228-df38df07441b", "rel": "bookmark"}], "name": "HS2-Large"}, {"id": "13623471-25c5-44e0-8e5a-f87f0ee79098", "links": [{"href": "http://our-openstack-server.com:8774/v2/our-project-id-uid/flavors/13623471-25c5-44e0-8e5a-f87f0ee79098", "rel": "self"}, {"href": "http://our-openstack-server.com:8774/our-project-id-uid/flavors/13623471-25c5-44e0-8e5a-f87f0ee79098", "rel": "bookmark"}], "name": "CO2-2XLarge"}, {"id": "22577f7e-fbc3-4bec-8f67-e88b5490e73d", "links": [{"href": "http://our-openstack-server.com:8774/v2/our-project-id-uid/flavors/22577f7e-fbc3-4bec-8f67-e88b5490e73d", "rel": "self"}, {"href": "http://our-openstack-server.com:8774/our-project-id-uid/flavors/22577f7e-fbc3-4bec-8f67-e88b5490e73d", "rel": "bookmark"}], "name": "HS2-6XLarge"}, {"id": "250d823f-29b4-4670-94ac-0e080823f178", "links": [{"href": "http://our-openstack-server.com:8774/v2/our-project-id-uid/flavors/250d823f-29b4-4670-94ac-0e080823f178", "rel": "self"}, {"href": "http://our-openstack-server.com:8774/our-project-id-uid/flavors/250d823f-29b4-4670-94ac-0e080823f178", "rel": "bookmark"}], "name": "SO2-4XLarge"}, {"id": "2a726160-132f-4125-a022-a55fb9817dec", "links": [{"href": "http://our-openstack-server.com:8774/v2/our-project-id-uid/flavors/2a726160-132f-4125-a022-a55fb9817dec", "rel": "self"}, {"href": "http://our-openstack-server.com:8774/our-project-id-uid/flavors/2a726160-132f-4125-a022-a55fb9817dec", "rel": "bookmark"}], "name": "MO2-XLarge"}, {"id": "2ad22f89-86b5-43fd-bea5-7b89a7d9b6e6", "links": [{"href": "http://our-openstack-server.com:8774/v2/our-project-id-uid/flavors/2ad22f89-86b5-43fd-bea5-7b89a7d9b6e6", "rel": "self"}, {"href": "http://our-openstack-server.com:8774/our-project-id-uid/flavors/2ad22f89-86b5-43fd-bea5-7b89a7d9b6e6", "rel": "bookmark"}], "name": "GP2-Large"}, {"id": "392af288-f5f9-4470-a296-b8790c80aadf", "links": [{"href": "http://our-openstack-server.com:8774/v2/our-project-id-uid/flavors/392af288-f5f9-4470-a296-b8790c80aadf", "rel": "self"}, {"href": "http://our-openstack-server.com:8774/our-project-id-uid/flavors/392af288-f5f9-4470-a296-b8790c80aadf", "rel": "bookmark"}], "name": "Micro-Small"}, {"id": "4210EB2C-827D-41B8-AEB0-810DD248AD07", "links": [{"href": "http://our-openstack-server.com:8774/v2/our-project-id-uid/flavors/4210EB2C-827D-41B8-AEB0-810DD248AD07", "rel": "self"}, {"href": "http://our-openstack-server.com:8774/our-project-id-uid/flavors/4210EB2C-827D-41B8-AEB0-810DD248AD07", "rel": "bookmark"}], "name": "small.csr1000v"}, {"id": "481efb41-2873-4eb0-a9f9-371f867a0e1c", "links": [{"href": "http://our-openstack-server.com:8774/v2/our-project-id-uid/flavors/481efb41-2873-4eb0-a9f9-371f867a0e1c", "rel": "self"}, {"href": "http://our-openstack-server.com:8774/our-project-id-uid/flavors/481efb41-2873-4eb0-a9f9-371f867a0e1c", "rel": "bookmark"}], "name": "CO2-Large"}, {"id": "48f812a3-8038-463c-bc23-a1f1d0b68085", "links": [{"href": "http://our-openstack-server.com:8774/v2/our-project-id-uid/flavors/48f812a3-8038-463c-bc23-a1f1d0b68085", "rel": "self"}, {"href": "http://our-openstack-server.com:8774/our-project-id-uid/flavors/48f812a3-8038-463c-bc23-a1f1d0b68085", "rel": "bookmark"}], "name": "GP2-2Xlarge"}, {"id": "59ec305f-3d30-4d6d-b155-6e702136a858", "links": [{"href": "http://our-openstack-server.com:8774/v2/our-project-id-uid/flavors/59ec305f-3d30-4d6d-b155-6e702136a858", "rel": "self"}, {"href": "http://our-openstack-server.com:8774/our-project-id-uid/flavors/59ec305f-3d30-4d6d-b155-6e702136a858", "rel": "bookmark"}], "name": "NOM2-XLarge"}, {"id": "5ade5e03-c2df-42d6-ad87-81a1a673a5cf", "links": [{"href": "http://our-openstack-server.com:8774/v2/our-project-id-uid/flavors/5ade5e03-c2df-42d6-ad87-81a1a673a5cf", "rel": "self"}, {"href": "http://our-openstack-server.com:8774/our-project-id-uid/flavors/5ade5e03-c2df-42d6-ad87-81a1a673a5cf", "rel": "bookmark"}], "name": "NO2-Large"}, {"id": "66ba491b-50e6-4e88-886a-20e57c72635d", "links": [{"href": "http://our-openstack-server.com:8774/v2/our-project-id-uid/flavors/66ba491b-50e6-4e88-886a-20e57c72635d", "rel": "self"}, {"href": "http://our-openstack-server.com:8774/our-project-id-uid/flavors/66ba491b-50e6-4e88-886a-20e57c72635d", "rel": "bookmark"}], "name": "CO2-Medium"}, {"id": "859f10bf-094a-4cdf-8d02-220b9efe0928", "links": [{"href": "http://our-openstack-server.com:8774/v2/our-project-id-uid/flavors/859f10bf-094a-4cdf-8d02-220b9efe0928", "rel": "self"}, {"href": "http://our-openstack-server.com:8774/our-project-id-uid/flavors/859f10bf-094a-4cdf-8d02-220b9efe0928", "rel": "bookmark"}], "name": "SO2-XLarge"}, {"id": "8a15d629-0c07-4749-98b2-dd66851e1752", "links": [{"href": "http://our-openstack-server.com:8774/v2/our-project-id-uid/flavors/8a15d629-0c07-4749-98b2-dd66851e1752", "rel": "self"}, {"href": "http://our-openstack-server.com:8774/our-project-id-uid/flavors/8a15d629-0c07-4749-98b2-dd66851e1752", "rel": "bookmark"}], "name": "MO2-2XLarge"}, {"id": "8b192b47-432e-4889-b2ea-ed62f7fedcd6", "links": [{"href": "http://our-openstack-server.com:8774/v2/our-project-id-uid/flavors/8b192b47-432e-4889-b2ea-ed62f7fedcd6", "rel": "self"}, {"href": "http://our-openstack-server.com:8774/our-project-id-uid/flavors/8b192b47-432e-4889-b2ea-ed62f7fedcd6", "rel": "bookmark"}], "name": "NOM2-Large"}, {"id": "900a16f5-8c6d-48e1-b96d-2a226e7aa5b5", "links": [{"href": "http://our-openstack-server.com:8774/v2/our-project-id-uid/flavors/900a16f5-8c6d-48e1-b96d-2a226e7aa5b5", "rel": "self"}, {"href": "http://our-openstack-server.com:8774/our-project-id-uid/flavors/900a16f5-8c6d-48e1-b96d-2a226e7aa5b5", "rel": "bookmark"}], "name": "NO2-2XLarge"}, {"id": "a062130a-4498-4156-9788-0fb7b2fa5c96", "links": [{"href": "http://our-openstack-server.com:8774/v2/our-project-id-uid/flavors/a062130a-4498-4156-9788-0fb7b2fa5c96", "rel": "self"}, {"href": "http://our-openstack-server.com:8774/our-project-id-uid/flavors/a062130a-4498-4156-9788-0fb7b2fa5c96", "rel": "bookmark"}], "name": "MO2-4XLarge"}, {"id": "ae657082-9ad3-4f58-8bfd-79346ba23131", "links": [{"href": "http://our-openstack-server.com:8774/v2/our-project-id-uid/flavors/ae657082-9ad3-4f58-8bfd-79346ba23131", "rel": "self"}, {"href": "http://our-openstack-server.com:8774/our-project-id-uid/flavors/ae657082-9ad3-4f58-8bfd-79346ba23131", "rel": "bookmark"}], "name": "CO2-FullSize"}, {"id": "b48b3856-9957-4635-8d36-20d80cdbf345", "links": [{"href": "http://our-openstack-server.com:8774/v2/our-project-id-uid/flavors/b48b3856-9957-4635-8d36-20d80cdbf345", "rel": "self"}, {"href": "http://our-openstack-server.com:8774/our-project-id-uid/flavors/b48b3856-9957-4635-8d36-20d80cdbf345", "rel": "bookmark"}], "name": "HS2-2XLarge"}, {"id": "b7bce09f-89b8-47e1-90cd-b9064354d2c0", "links": [{"href": "http://our-openstack-server.com:8774/v2/our-project-id-uid/flavors/b7bce09f-89b8-47e1-90cd-b9064354d2c0", "rel": "self"}, {"href": "http://our-openstack-server.com:8774/our-project-id-uid/flavors/b7bce09f-89b8-47e1-90cd-b9064354d2c0", "rel": "bookmark"}], "name": "GP2-Xlarge"}, {"id": "b8cab14f-44c5-4e9f-b58e-78de931b85f4", "links": [{"href": "http://our-openstack-server.com:8774/v2/our-project-id-uid/flavors/b8cab14f-44c5-4e9f-b58e-78de931b85f4", "rel": "self"}, {"href": "http://our-openstack-server.com:8774/our-project-id-uid/flavors/b8cab14f-44c5-4e9f-b58e-78de931b85f4", "rel": "bookmark"}], "name": "HS2-XLarge"}, {"id": "c2516854-f8b4-4abb-b476-36eb80e32d6f", "links": [{"href": "http://our-openstack-server.com:8774/v2/our-project-id-uid/flavors/c2516854-f8b4-4abb-b476-36eb80e32d6f", "rel": "self"}, {"href": "http://our-openstack-server.com:8774/our-project-id-uid/flavors/c2516854-f8b4-4abb-b476-36eb80e32d6f", "rel": "bookmark"}], "name": "GP2-Medium"}, {"id": "c553c236-034b-41c5-9439-1399bb2d3cf8", "links": [{"href": "http://our-openstack-server.com:8774/v2/our-project-id-uid/flavors/c553c236-034b-41c5-9439-1399bb2d3cf8", "rel": "self"}, {"href": "http://our-openstack-server.com:8774/our-project-id-uid/flavors/c553c236-034b-41c5-9439-1399bb2d3cf8", "rel": "bookmark"}], "name": "SO2-2XLarge"}, {"id": "cbd2247f-8df0-4887-881f-7495242054c0", "links": [{"href": "http://our-openstack-server.com:8774/v2/our-project-id-uid/flavors/cbd2247f-8df0-4887-881f-7495242054c0", "rel": "self"}, {"href": "http://our-openstack-server.com:8774/our-project-id-uid/flavors/cbd2247f-8df0-4887-881f-7495242054c0", "rel": "bookmark"}], "name": "CO2-XLarge"}, {"id": "e326b633-b708-4ab5-b5b3-24d432356a16", "links": [{"href": "http://our-openstack-server.com:8774/v2/our-project-id-uid/flavors/e326b633-b708-4ab5-b5b3-24d432356a16", "rel": "self"}, {"href": "http://our-openstack-server.com:8774/our-project-id-uid/flavors/e326b633-b708-4ab5-b5b3-24d432356a16", "rel": "bookmark"}], "name": "MO2-Large"}, {"id": "e839edfb-1476-45ce-8706-e1f2090346f3", "links": [{"href": "http://our-openstack-server.com:8774/v2/our-project-id-uid/flavors/e839edfb-1476-45ce-8706-e1f2090346f3", "rel": "self"}, {"href": "http://our-openstack-server.com:8774/our-project-id-uid/flavors/e839edfb-1476-45ce-8706-e1f2090346f3", "rel": "bookmark"}], "name": "SO2-Large"}, {"id": "e848301a-f676-4259-8e4a-a9e51c2f2f4f", "links": [{"href": "http://our-openstack-server.com:8774/v2/our-project-id-uid/flavors/e848301a-f676-4259-8e4a-a9e51c2f2f4f", "rel": "self"}, {"href": "http://our-openstack-server.com:8774/our-project-id-uid/flavors/e848301a-f676-4259-8e4a-a9e51c2f2f4f", "rel": "bookmark"}], "name": "NO2-XLarge"}, {"id": "ebdf2907-895f-47ae-bb4c-2a9ae163f4af", "links": [{"href": "http://our-openstack-server.com:8774/v2/our-project-id-uid/flavors/ebdf2907-895f-47ae-bb4c-2a9ae163f4af", "rel": "self"}, {"href": "http://our-openstack-server.com:8774/our-project-id-uid/flavors/ebdf2907-895f-47ae-bb4c-2a9ae163f4af", "rel": "bookmark"}], "name": "SO2-2XMLarge"}, {"id": "f6f70b57-f0e4-4343-8412-b5a9b9e7db18", "links": [{"href": "http://our-openstack-server.com:8774/v2/our-project-id-uid/flavors/f6f70b57-f0e4-4343-8412-b5a9b9e7db18", "rel": "self"}, {"href": "http://our-openstack-server.com:8774/our-project-id-uid/flavors/f6f70b57-f0e4-4343-8412-b5a9b9e7db18", "rel": "bookmark"}], "name": "HS2-4XLarge"}]}

DEBUG (session:198) REQ: curl -g -i -X GET https://our-openstack-server.com:8774/v2/our-project-id-uid/flavors/392af288-f5f9-4470-a296-b8790c80aadf -H "User-Agent: python-novaclient" -H "Accept: application/json" -H "X-Auth-Token: {SHA1}OUR-SHA-KEY"
DEBUG (connectionpool:383) "GET /v2/our-project-id-uid/flavors/392af288-f5f9-4470-a296-b8790c80aadf HTTP/1.1" 200 561
DEBUG (session:216) RESP: [200] content-length: 561 via: 1.1 Repose (Repose/7.1.4.0) x-compute-request-id: req-665613f3-d482-447d-b215-c7c6aa2be20d server: Jetty(9.2.z-SNAPSHOT) x-trans-id: 2187dbae-b624-425b-9d4a-b6433083cca8 date: Wed, 06 Jan 2016 19:18:36 GMT, Wed, 06 Jan 2016 19:18:36 GMT content-type: application/json 
RESP BODY: {"flavor": {"name": "Micro-Small", "links": [{"href": "http://our-openstack-server.com:8774/v2/our-project-id-uid/flavors/392af288-f5f9-4470-a296-b8790c80aadf", "rel": "self"}, {"href": "http://our-openstack-server.com:8774/our-project-id-uid/flavors/392af288-f5f9-4470-a296-b8790c80aadf", "rel": "bookmark"}], "ram": 2048, "OS-FLV-DISABLED:disabled": false, "vcpus": 1, "swap": "", "os-flavor-access:is_public": true, "rxtx_factor": 1.0, "OS-FLV-EXT-DATA:ephemeral": 0, "disk": 50, "id": "392af288-f5f9-4470-a296-b8790c80aadf"}}

DEBUG (session:198) REQ: curl -g -i -X POST https://our-openstack-server.com:8774/v2/our-project-id-uid/servers -H "User-Agent: python-novaclient" -H "Content-Type: application/json" -H "Accept: application/json" -H "X-Auth-Token: {SHA1}OUR-SHA-KEY" -d '{"server": {"name": "ASAv-day-0-v5", "imageRef": "a85692b5-3a5f-42f9-bbed-cb6832826992", "flavorRef": "392af288-f5f9-4470-a296-b8790c80aadf", "max_count": 1, "min_count": 1, "personality": [{"path": "day0", "contents": "aG9zdG5hbWUgYXNhdi1kYXktMAppbnRlcmZhY2UgR2lnYWJpdEV0aGVybmV0MC8wCiBuYW1laWYgb3V0c2lkZQoK"}], "networks": [{"uuid": "bd07df1c-632e-4fa4-a7bb-77f7df46abbf"}, {"uuid": "21ade440-3483-4b5f-9de7-2268f7d393da"}], "config_drive": true}}'
DEBUG (connectionpool:383) "POST /v2/our-project-id-uid/servers HTTP/1.1" 202 468
DEBUG (session:216) RESP: [202] content-length: 468 via: 1.1 Repose (Repose/7.1.4.0) x-compute-request-id: req-0b802f21-4269-4db3-93cf-c54fc955d8f8 server: Jetty(9.2.z-SNAPSHOT) location: https://our-openstack-server.com:8774/v2/our-project-id-uid/servers/fd492e84-840b-44aa-8122-fa4621228a19 x-trans-id: bde45b7e-ef85-498d-b14c-f445ba58149a date: Wed, 06 Jan 2016 19:18:36 GMT, Wed, 06 Jan 2016 19:18:36 GMT content-type: application/json 
RESP BODY: {"server": {"security_groups": [{"name": "default"}], "OS-DCF:diskConfig": "MANUAL", "id": "fd492e84-840b-44aa-8122-fa4621228a19", "links": [{"href": "http://our-openstack-server.com:8774/v2/our-project-id-uid/servers/fd492e84-840b-44aa-8122-fa4621228a19", "rel": "self"}, {"href": "http://our-openstack-server.com:8774/our-project-id-uid/servers/fd492e84-840b-44aa-8122-fa4621228a19", "rel": "bookmark"}], "adminPass": "***"}}

DEBUG (session:198) REQ: curl -g -i -X GET https://our-openstack-server.com:8774/v2/our-project-id-uid/servers/fd492e84-840b-44aa-8122-fa4621228a19 -H "User-Agent: python-novaclient" -H "Accept: application/json" -H "X-Auth-Token: {SHA1}OUR-SHA-KEY"
DEBUG (connectionpool:383) "GET /v2/our-project-id-uid/servers/fd492e84-840b-44aa-8122-fa4621228a19 HTTP/1.1" 200 1433
DEBUG (session:216) RESP: [200] content-length: 1433 via: 1.1 Repose (Repose/7.1.4.0) x-compute-request-id: req-71b69558-b863-4a1d-9af2-7330b3d06059 server: Jetty(9.2.z-SNAPSHOT) x-trans-id: 618d748d-1803-45d4-9c1e-a8d6c47357e4 date: Wed, 06 Jan 2016 19:18:36 GMT, Wed, 06 Jan 2016 19:18:36 GMT content-type: application/json 
RESP BODY: {"server": {"status": "BUILD", "updated": "2016-01-06T19:18:36Z", "hostId": "", "addresses": {}, "links": [{"href": "http://our-openstack-server.com:8774/v2/our-project-id-uid/servers/fd492e84-840b-44aa-8122-fa4621228a19", "rel": "self"}, {"href": "http://our-openstack-server.com:8774/our-project-id-uid/servers/fd492e84-840b-44aa-8122-fa4621228a19", "rel": "bookmark"}], "key_name": null, "image": {"id": "a85692b5-3a5f-42f9-bbed-cb6832826992", "links": [{"href": "http://our-openstack-server.com:8774/our-project-id-uid/images/a85692b5-3a5f-42f9-bbed-cb6832826992", "rel": "bookmark"}]}, "OS-EXT-STS:task_state": "scheduling", "OS-EXT-STS:vm_state": "building", "OS-SRV-USG:launched_at": null, "flavor": {"id": "392af288-f5f9-4470-a296-b8790c80aadf", "links": [{"href": "http://our-openstack-server.com:8774/our-project-id-uid/flavors/392af288-f5f9-4470-a296-b8790c80aadf", "rel": "bookmark"}]}, "id": "fd492e84-840b-44aa-8122-fa4621228a19", "OS-SRV-USG:terminated_at": null, "OS-EXT-AZ:availability_zone": "nova", "user_id": "4b4303f7d616407dab47ef543d875393", "name": "ASAv-day-0-v5", "created": "2016-01-06T19:18:36Z", "tenant_id": "our-project-id-uid", "OS-DCF:diskConfig": "MANUAL", "os-extended-volumes:volumes_attached": [], "accessIPv4": "", "accessIPv6": "", "progress": 0, "OS-EXT-STS:power_state": 0, "config_drive": "True", "metadata": {}}}

DEBUG (session:198) REQ: curl -g -i -X GET https://our-openstack-server.com:8774/v2/our-project-id-uid/flavors/392af288-f5f9-4470-a296-b8790c80aadf -H "User-Agent: python-novaclient" -H "Accept: application/json" -H "X-Auth-Token: {SHA1}OUR-SHA-KEY"
DEBUG (connectionpool:383) "GET /v2/our-project-id-uid/flavors/392af288-f5f9-4470-a296-b8790c80aadf HTTP/1.1" 200 561
DEBUG (session:216) RESP: [200] content-length: 561 via: 1.1 Repose (Repose/7.1.4.0) x-compute-request-id: req-fbba104c-810d-4673-8b73-2975fad3f8c6 server: Jetty(9.2.z-SNAPSHOT) x-trans-id: 1e1e609d-2b70-4d42-876f-6472e5a89d22 date: Wed, 06 Jan 2016 19:18:37 GMT, Wed, 06 Jan 2016 19:18:37 GMT content-type: application/json 
RESP BODY: {"flavor": {"name": "Micro-Small", "links": [{"href": "http://our-openstack-server.com:8774/v2/our-project-id-uid/flavors/392af288-f5f9-4470-a296-b8790c80aadf", "rel": "self"}, {"href": "http://our-openstack-server.com:8774/our-project-id-uid/flavors/392af288-f5f9-4470-a296-b8790c80aadf", "rel": "bookmark"}], "ram": 2048, "OS-FLV-DISABLED:disabled": false, "vcpus": 1, "swap": "", "os-flavor-access:is_public": true, "rxtx_factor": 1.0, "OS-FLV-EXT-DATA:ephemeral": 0, "disk": 50, "id": "392af288-f5f9-4470-a296-b8790c80aadf"}}

DEBUG (session:198) REQ: curl -g -i -X GET https://our-openstack-server.com:8774/v2/our-project-id-uid/images/a85692b5-3a5f-42f9-bbed-cb6832826992 -H "User-Agent: python-novaclient" -H "Accept: application/json" -H "X-Auth-Token: {SHA1}OUR-SHA-KEY"
DEBUG (connectionpool:383) "GET /v2/our-project-id-uid/images/a85692b5-3a5f-42f9-bbed-cb6832826992 HTTP/1.1" 200 824
DEBUG (session:216) RESP: [200] content-length: 824 via: 1.1 Repose (Repose/7.1.4.0) x-compute-request-id: req-cb40f6d2-c0eb-46cf-a307-39e30b980ab7 server: Jetty(9.2.z-SNAPSHOT) x-trans-id: f23e4e77-cd20-42b2-86b9-b4bd9c2eb756 date: Wed, 06 Jan 2016 19:18:37 GMT, Wed, 06 Jan 2016 19:18:37 GMT content-type: application/json 
RESP BODY: {"image": {"status": "ACTIVE", "updated": "2016-01-06T16:02:30Z", "links": [{"href": "http://our-openstack-server.com:8774/v2/our-project-id-uid/images/a85692b5-3a5f-42f9-bbed-cb6832826992", "rel": "self"}, {"href": "http://our-openstack-server.com:8774/our-project-id-uid/images/a85692b5-3a5f-42f9-bbed-cb6832826992", "rel": "bookmark"}, {"href": "http://our-openstack-server:9292/our-project-id-uid/images/a85692b5-3a5f-42f9-bbed-cb6832826992", "type": "application/vnd.openstack.image", "rel": "alternate"}], "id": "a85692b5-3a5f-42f9-bbed-cb6832826992", "OS-EXT-IMG-SIZE:size": 169017344, "name": "ASAv-9.5.2-QCOW2", "created": "2016-01-06T14:36:21Z", "minDisk": 0, "progress": 100, "minRam": 0, "metadata": {"os_distro": "Unknown", "os_name": "Unknown", "os_version": "Unknown"}}}

+--------------------------------------+---------------------------------------------------------+
| Property                             | Value                                                   |
+--------------------------------------+---------------------------------------------------------+
| OS-DCF:diskConfig                    | MANUAL                                                  |
| OS-EXT-AZ:availability_zone          | nova                                                    |
| OS-EXT-STS:power_state               | 0                                                       |
| OS-EXT-STS:task_state                | scheduling                                              |
| OS-EXT-STS:vm_state                  | building                                                |
| OS-SRV-USG:launched_at               | -                                                       |
| OS-SRV-USG:terminated_at             | -                                                       |
| accessIPv4                           |                                                         |
| accessIPv6                           |                                                         |
| adminPass                            | -                                           |
| config_drive                         | True                                                    |
| created                              | 2016-01-06T19:18:36Z                                    |
| flavor                               | Micro-Small (392af288-f5f9-4470-a296-b8790c80aadf)      |
| hostId                               |                                                         |
| id                                   | fd492e84-840b-44aa-8122-fa4621228a19                    |
| image                                | ASAv-9.5.2-QCOW2 (a85692b5-3a5f-42f9-bbed-cb6832826992) |
| key_name                             | -                                                       |
| metadata                             | {}                                                      |
| name                                 | ASAv-day-0-v5                                           |
| os-extended-volumes:volumes_attached | []                                                      |
| progress                             | 0                                                       |
| security_groups                      | default                                                 |
| status                               | BUILD                                                   |
| tenant_id                            | our-project-id-uid                        |
| updated                              | 2016-01-06T19:18:36Z                                    |
| user_id                              | -                       |
+--------------------------------------+---------------------------------------------------------+
jtopjian commented 8 years ago

Thanks!

It looks like Gophercloud has support for personalities, which means that only Terraform needs to be modified. This doesn't look hard to do. Hopefully I can get to this within the next week.

aunraza commented 8 years ago

Fantastic! Thanks for your help!

jtopjian commented 8 years ago

If you guys are able to build from source, check out #4623 and let me know if you have any issues. :smile:

aunraza commented 8 years ago

Thanks. I looked through the changes, and noticed that the following is how it needs to be done, however, I don't understand what the "contents" field under personality is for:

personality {
    file = "/home/user/filename.txt"
    contents = ???
}

The configuration that we need to push to the instance is what is in the file.

jtopjian commented 8 years ago

The contents would be the actual contents of the destination file:

personality {
  file = "/path/to/remote/day0"
  contents = "${file("/path/to/local/day-0.config")}"
}
aunraza commented 8 years ago

Thanks again. On a separate note, how do we check out your change and then build from it? Apologies in advance for the daftness.

jtopjian commented 8 years ago

Absolutely not daft. It's a process taken for granted :smile:

Take a look at the Terraform README for some background information. Next, I have a script used for the OpenStack acceptance tests here.

Running everything up to line 19 (or translating it for the OS/distro you're using) should get you a basic Go environment. Once you've run make updatedeps, do the following:

git remote add jtopjian https://github.com/jtopjian/terraform
git fetch jtopjian
git checkout --track jtopjian/openstack-instance-personality
make plugin-dev PLUGIN=provider-openstack

Then copy the resulting binary from ~/go/bin/terraform-provider-openstack to your Terraform installation dir.

I might have missed a step, so let me know if you need help or need anything clarified.

aunraza commented 8 years ago

Thanks Joe. So the good news is that I was able to follow your steps and get the provider plugin updated - your instructions were perfect. I put the following in the .tf file however, it didn't seem to work as it does with nova:

config_drive = "true"
personality {
    file = "day0=asa-day0.config"
    content = "${file("/path/to/terraform/asa-day0.config")}"
}

Similarly, I did that for the CSR as well, and gave it the following:

config_drive = "true"
personality {
    file = "csr-day0.config"
    content = "${file("/home/cloud-user/terraform/csr-day0.config")}"
}

However, they didn't seem to load the configs.

This is what the output showed in terraform for the personality - didn't indicate any errors:

personality.#:                 "" => "1"
personality.889800003.content: "" => "service timestamps debug datetime msec\nservice timestamps log datetime msec\n <snip>
.
.
personality.889800003.file:    "" => "csr-day0.config"
aunraza commented 8 years ago

Joe, one thing to note is that specifically for the ASA, when we specify the "file" keyword in the nova command, the following is what we specify: --file day0=day0.config, where day0.config is the path to the day0.config file. In the case of the CSR, we just specify the path to the file, and nothing else. The remote systems don't really have a path that they can reference and just load something similar to a CD drive (the config-drive in our case), and if there is one, they read the day0.config directly from there.

jtopjian commented 8 years ago

I think you're still passing the parameters in wrong. If you were to do the following on the command line:

--file day0=asa-day0.config

It now looks like this in Terraform:

personality {
  file = "day0"
  content = "${file("asa-day0.config")}"
}

Let me know if that helps.

aunraza commented 8 years ago

Joe, spot on! That seems to have done it! Thank you! Apologies for the constant back and forth!

jtopjian commented 8 years ago

Awesome - glad everything is working and no problem at all! :smile:

I'll get the PR merged later on this evening.

ghost commented 4 years ago

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.