Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not automatacly installing with Cloud-init #43

Open
zwarthoorn opened this issue Jul 15, 2021 · 3 comments
Open

Not automatacly installing with Cloud-init #43

zwarthoorn opened this issue Jul 15, 2021 · 3 comments

Comments

@zwarthoorn
Copy link

In the documentation i find that you can put a cloud-init file (or parts of it) inside the installer text.
i have a valid cloud-init file for setting up de vps on ubuntu the only thing i get thrown with transip is when the vps is set up that the file that is delivered and read is unreadable or corrupted.

Question is am i doing somthing wrong or is it not supported

@aequitas
Copy link
Owner

That part is currently not well tested so might be there is a bug in the code. Can you share a code snippet of the vps resource and how you provide the cloud init file to it so I can use that to test it?

@zwarthoorn
Copy link
Author

I do have 2 snipets for you i have dedacted some personal information but you can get the gist of out of it

resource "transip_vps" "Dgrbot" {
  product_name = "vps-bladevps-x1"
  operating_system = "ubuntu-20.04"

  # Script to run to provision the VPS
  install_text = <<EOF
I2Nsb3VkLWNvbmZpZw0KcGFja2FnZV91cGdyYWRlOiB0cnVlDQpwYWNrYWdlczoNCiAgLSBuZ2lueA0KICAtIGdpdA0KICAtIGN1cmwNCiAgLSBjaHJvbWl1bS1ic3UNCiAgLSBsaWJnYm0xDQogIC0gbGlibnNzMw0KICAtIGxpYnhzczENCiAgLSBsaWJhc291bmQyDQogIC0gbGliYXRrLWJyaWRnZTIuMC0wDQogIC0gbGliZ3RrLTMtMA0Kd3JpdGVfZmlsZXM6DQogIC0gb3duZXI6IHd3dy1kYXRhOnd3dy1kYXRhDQogICAgcGF0aDogL2V0Yy9uZ2lueC9zaXRlcy1hdmFpbGFibGUvZGVmYXVsdA0KICAgIGNvbnRlbnQ6IHwNCiAgICAgIHNlcnZlciB7DQogICAgICAgIGxpc3RlbiA4MDsNCiAgICAgICAgbG9jYXRpb24gLyB7DQogICAgICAgICAgcHJveHlfcGFzcy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wgaHR0cHM6Ly9kZWIubm9kZXNvdXJjZS5jb20vc2V0dXBfMTQueCAtbyBzZXR1cF8xNC5zaA0KICAtIHNoIC4vc2V0dXBfMTQuc2gNCiAgLSBhcHQgdXBkYXRlDQogIC0gYXB0IGluc3RhbGwgbm9kZWpzDQogIC0gbnBtIGluc3RhbGwgLS1nbG9iYWwgeWFybg===+DQogIC0gY3VybCAtc0wgaHR0cHM6Ly9kZWIubm9kZXNvdXJjZS5jb20vc2V0dXBfMTQueCAtbyBzZXR1cF8xNC5zaA0KICAtIHNoIC4vc2V0dXBfMTQuc2gNCiAgLSBhcHQgdXBkYXRlDQogIC0gYXB0IGluc3RhbGwgbm9kZWpzDQogIC0gbnBtIGluc3RhbGwgLS1nbG9iYWwgeWFybg0KICAtIGdpdCBjbG9uZSBodHRwczovL3p3YXJ0aG9vcm46Z2hwX1BQcmp1TzlYNXg1THFnMTlxVTMxOTBUc1hYRlBJMDJlSko4ZkBnaXRodWIuY29tL1ZDU1dCVi9ER1JCb3QtdjIuZ2l0DQogIC0gY2QgREdSQm90LXYyDQogIC0geWFybiBpbnN0YWxsDQogIC0gbXYgY29uZmlnLmV4YW1wbGUuanNvbiBjb25maWcuanNvbg0KICAtIG5wbSBpbnN0YWxsIC1nIHBtMg0KICAtIHVmdyBhbGxvdyAyMi90Y3ANCiAgLSB1ZncgYWxsb3cgODAvdGNwDQogIC0gdWZ3IGFsbG93IDQ0My90Y3ANCiAgLSB1ZncgLS1mb3JjZSBlbmFibGUNCg==
  EOF
}```


``` # VPS Server with setup script and DNS record
resource "transip_vps" "Dgrbot" {
  product_name = "vps-bladevps-x1"
  operating_system = "ubuntu-20.04"

  # Script to run to provision the VPS
  install_text = <<EOF
#cloud-config
package_upgrade: true
packages:
  - nginx
  - git
  - curl
  - chromium-bsu
  - libgbm1
  - libnss3
  - libxss1
  - libasound2
  - libatk-bridge2.0-0
  - libgtk-3-0
write_files:
  - owner: www-data:www-data
    path: /etc/nginx/sites-available/default
    content: |
      server {
        listen 80;
        location / {
          proxy_pass http://localhost:61002;
          proxy_http_version 1.1;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection keep-alive;
          proxy_set_header Host $host;
          proxy_cache_bypass $http_upgrade;
        }
      }
users:
  - name: test
    groups: sudo
    homedir: /werk/home/test
    shell: /bin/bash
    sudo: [ 'ALL=(ALL) NOPASSWD:ALL' ]
#    ssh-authorized-keys:
#      -
  - name: test2
      groups: sudo
      homedir: /werk/home/test2
      shell: /bin/bash
      sudo: [ 'ALL=(ALL) NOPASSWD:ALL' ]
#      ssh-authorized-keys:
#        -
  - name: test3
      groups: sudo
      homedir: /werk/home/test3
      shell: /bin/bash
      sudo: [ 'ALL=(ALL) NOPASSWD:ALL' ]
#      ssh-authorized-keys:
#        -

runcmd:
  - cd ~
  - curl -sL https://deb.nodesource.com/setup_14.x -o setup_14.sh
  - sh ./setup_14.sh
  - apt update
  - apt install nodejs
  - npm install --global yarn
  EOF
}```


@aequitas
Copy link
Owner

Thanks, you should not have to base64 encode the data yourself like the first. The second example should be how it should work. I'll test this locally and get back to you with why it doesn't.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants