Cloud-config

From Federal Burro of Information
Jump to navigationJump to search

sample file:

source: https://docs.microsoft.com/en-us/azure/virtual-machines/linux/tutorial-automate-vm-deployment

#cloud-config
package_update: true
package_upgrade: true
packages:
  - nginx
  - nodejs
  - npm
  - vim
  - iputils-ping
  - lsof
  - telnet
  - iptraf-ng
  - apt-utils


write_files:
  - owner: www-data:www-data
    path: /etc/nginx/sites-available/default
    content: |
      server {
        listen 80;
        location / {
          proxy_pass http://localhost:3000;
          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;
        }
      }
  - owner: azureuser:azureuser
    path: /home/azureuser/myapp/index.js
    content: |
      var express = require('express')
      var app = express()
      var os = require('os');
      app.get('/', function (req, res) {
        res.send('Hello World from host ' + os.hostname() + '!')
      })
      app.listen(3000, function () {
        console.log('Hello world app listening on port 3000!')
      })
runcmd:
  - echo "curl agent"
  - curl -sSO https://dl.google.com/cloudagents/add-monitoring-agent-repo.sh
  - echo "bash script"
  - bash add-monitoring-agent-repo.sh
  - echo "apt update
  - apt-get update
  - apt-get install -y "stackdriver-agent"
  - service stackdriver-agent start
  - service nginx restart
  - cd "/home/azureuser/myapp"
  - npm init
  - npm install express -y
  - nodejs index.js


/nat box