Cloud-config: Difference between revisions

From Federal Burro of Information
Jump to navigationJump to search
(Created page with "sample file: source: https://docs.microsoft.com/en-us/azure/virtual-machines/linux/tutorial-automate-vm-deployment <pre> #cloud-config package_upgrade: true packages: - ng...")
 
No edit summary
Line 5: Line 5:
<pre>
<pre>
#cloud-config
#cloud-config
package_update: true
package_upgrade: true
package_upgrade: true
packages:
packages:
Line 10: Line 11:
   - nodejs
   - nodejs
   - npm
   - npm
write_files:
write_files:
   - owner: www-data:www-data
   - owner: www-data:www-data
Line 38: Line 40:
       })
       })
runcmd:
runcmd:
  - curl -sSO https://dl.google.com/cloudagents/add-monitoring-agent-repo.sh
  - bash add-monitoring-agent-repo.sh
  - apt-get update
  - apt-get install -y 'stackdriver-agent'
  - service stackdriver-agent start
   - service nginx restart
   - service nginx restart
   - cd "/home/azureuser/myapp"
   - cd "/home/azureuser/myapp"
Line 43: Line 50:
   - npm install express -y
   - npm install express -y
   - nodejs index.js
   - nodejs index.js
</pre>
</pre>

Revision as of 21:29, 1 December 2020

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

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:
  - curl -sSO https://dl.google.com/cloudagents/add-monitoring-agent-repo.sh
  - bash add-monitoring-agent-repo.sh
  - 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