Skip to main content

SHELL PROVISIONER

we need to create one dir 

mkdir cloud

wget url (sample website)


----------------------------------


unzip moon.zip

rm -rf moon.zip

cp -rvf moon/* .

rm -rf moon





 VIM JJ.JSON


{


       "builders": [

           {


           "type": "amazon-ebs",

           "region": "us-east-1",

           "access_key": "AKQ",

           "secret_key": "Kfaurid",

           "instance_type": "t2.micro",

           "source_ami": "ami-02e136e904f3da870",

           "ssh_username": "ec2-user",

           "ami_name": "moon-amiiii"



           }


       ],


       "provisioners": [


               {


               "type": "file",

               "source": "./code/",                                --- inside code we have website files

               "destination": "/tmp"

               },



               {

                    "type": "shell",

                    "inline": [

                       "sleep 30",

                       "sudo yum update -y",

                       "sudo yum install httpd -y",

                       "sudo cp -rvf /tmp/* /var/www/html",       --  once it copy code then remove tmp and paste it on /var/www

                       "sudo service httpd start",

                       "sudo chkconfig httpd on",

                      

               ]



           }


       ]


}


Comments

Popular posts from this blog

Packer Environment Variable

Note:  1011  export AWS_ACCESS=AKGQ                         do this on console not on editor  1012  export AWS_SECRET=KfVkt1aurid  1013  echo $AWS_ACCESS  1014  AKVUGQ   vim moon.json {     "variables": {       "aws_access_key": "{{env `AWS_ACCESS`}}",       "aws_secret_key": "{{env `AWS_SECRET`}}"     },        "builders": [            {            "type": "amazon-ebs",            "region": "us-east-1",            "access_key": "{{user `aws_access_key`}}",            "secret_key": "{{user `aws_secret_key`}}",            "instance_type": "t2.micro",            "source_ami": "ami-02e136e904f3da870", ...

copying snap from one REGION to another

 while copying snap from one to another we need to change region provider "aws" {   region     = "us-west-1"   access_key = "AGQ"   secret_key = "Kurid" } resource "aws_ebs_snapshot_copy" "example_copy" {   source_snapshot_id = "snap-08bc5c27dad8e82b3"   source_region      = "us-east-1"   tags = {     Name = "HelloWorld_copy_snap"   } }

ONLY & MULTIPLE PARAMTER IN PACKER

if we have to define 3 builders from different services azure, gcp,aws here we can  provisioner will run on all builders  if we want to run on specific builder then we can use only parameter  "only": ["prod-team","test-team"]  {        "builders": [            {            "name": "test-team",            "type": "amazon-ebs",            "access_key": "AUGQ",            "secret_key": "Kaurid",            "region": "us-east-1",            "instance_type": "t2.micro",            "source_ami": "ami-02e136e904f3da870",            "ssh_username": "ec2-user",            "ami_name": "test-team-{{timestamp}}"            },   ...