New Question
0

Failure running multipart shellscript with Terraform and OpenStack

asked 2020-04-29 19:21:15 +0200

dev-rowbot gravatar image

Hi,

I am hitting an issue when launching Windows 2012R2 images on OpenStack Stein using Terraform. I initially thought though issue was with my image but I have used the "eval" image from Cloudbase and the results are the same. Cloud-init is working fine and all the standard provisioning seems to work but when I try execute multipart userdata that consists of 2 shell scripts fail to execute.

The backtrace for each script is identical:

2020-04-29 14:04:58.381 924 DEBUG cloudbaseinit.plugins.common.userdata [-] Executing userdata plugin: ShellScriptPlugin _process_part c:\program files\cloudbase solutions\cloudbase-init\python\lib\site-packages\cloudbaseinit\plugins\common\userdata.py:145
2020-04-29 14:04:58.396 924 ERROR cloudbaseinit.plugins.common.userdata [-] Exception during multipart part handling: text/x-shellscript, None
2020-04-29 14:04:58.412 924 ERROR cloudbaseinit.plugins.common.userdata [-] object of type 'NoneType' has no len()
2020-04-29 14:04:58.412 924 ERROR cloudbaseinit.plugins.common.userdata Traceback (most recent call last):
2020-04-29 14:04:58.412 924 ERROR cloudbaseinit.plugins.common.userdata   File "c:\program files\cloudbase solutions\cloudbase-init\python\lib\site-packages\cloudbaseinit\plugins\common\userdata.py", line 153, in _process_part
2020-04-29 14:04:58.412 924 ERROR cloudbaseinit.plugins.common.userdata     ret_val = user_data_plugin.process(part)
2020-04-29 14:04:58.412 924 ERROR cloudbaseinit.plugins.common.userdata   File "c:\program files\cloudbase solutions\cloudbase-init\python\lib\site-packages\cloudbaseinit\plugins\common\userdataplugins\shellscript.py", line 36, in process
2020-04-29 14:04:58.412 924 ERROR cloudbaseinit.plugins.common.userdata     target_path = os.path.join(tempfile.gettempdir(), file_name)
2020-04-29 14:04:58.412 924 ERROR cloudbaseinit.plugins.common.userdata   File "c:\program files\cloudbase solutions\cloudbase-init\python\lib\ntpath.py", line 110, in join
2020-04-29 14:04:58.412 924 ERROR cloudbaseinit.plugins.common.userdata     p_drive, p_path = splitdrive(p)
2020-04-29 14:04:58.412 924 ERROR cloudbaseinit.plugins.common.userdata   File "c:\program files\cloudbase solutions\cloudbase-init\python\lib\ntpath.py", line 159, in splitdrive
2020-04-29 14:04:58.412 924 ERROR cloudbaseinit.plugins.common.userdata     if len(p) > 1:
2020-04-29 14:04:58.412 924 ERROR cloudbaseinit.plugins.common.userdata TypeError: object of type 'NoneType' has no len()
2020-04-29 14:04:58.412 924 ERROR cloudbaseinit.plugins.common.userdata

I am not sure where to start looking for a solution.

I have pasted the full output here: https://pastebin.com/FkpGQfWK

edit retag flag offensive close merge delete

2 answers

Sort by » oldest newest most voted
1

answered 2020-05-05 16:51:49 +0200

dev-rowbot gravatar image

updated 2020-05-05 16:54:22 +0200

Quite by chance I managed to figure out why this is failing. When creating the terraform template_cloudinit_config I had not specified a filename for each of these scripts. According to the terraform documentation this is "optional" and I had assumed that a generic/temporary name would be created.

The eventual working configuration that worked is:

data "template_cloudinit_config" "config" {
  gzip          = true
  base64_encode = true

  part {
    filename     = "disable-ipv6.ps1"
    content_type = "text/x-shellscript"
    content      = file("${path.cwd}/scripts/disable-ipv6.ps1")
  }

  part {
    filename     = "configure-firewalls.ps1"
    content_type = "text/x-shellscript"
    content      = file("${path.cwd}/scripts/configure-firewalls.ps1")
  }
}

Should this be logged as a bug? If filename is considered optional shouldn't cloudbase init handle this when processing multipart mimedata?

edit flag offensive delete link more
0

answered 2020-05-12 18:13:46 +0200

avladu gravatar image

Hello,

Thank you for the report. It seems this is an actual bug in cloudbase-init, as the x-shellscript should be executed at boot time and not persisted on the disk.

edit flag offensive delete link more

Comments

ok great - should I open a issue on the cloudbase github page with these same details?

dev-rowbot gravatar imagedev-rowbot ( 2020-05-13 12:00:56 +0200 )edit
avladu gravatar imageavladu ( 2020-05-13 17:54:46 +0200 )edit

Great - thank you

dev-rowbot gravatar imagedev-rowbot ( 2020-05-13 18:57:02 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-04-29 19:21:15 +0200

Seen: 1,228 times

Last updated: May 12 '20