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

Create AMI using packer

 basic parameter vim moon.json  {        "builders": [            {            "type": "amazon-ebs",            "access_key": "AGQ",            "secret_key": "Kft1aurid",            "region": "us-east-1",            "instance_type": "t2.micro",            "source_ami": "ami-02e136e904f3da870",            "ssh_username": "ec2-user",            "ami_name": "moon-amiii"         }        ] } convert json file into hcl  packer hcl2 upgrade moon.json validate code  packer validate moon.json   packer validate moon.json.pkr.hcl

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", ...

ANSIBLE REMOTE-PROVISIONER

 NOTE:   974  mkdir sourcepath   975  cd sourcepath/   976  wget https://www.free-css.com/assets/files/free-css-templates/download/page276/transportz.zip   977  ll   978  unzip transportz.zip   979  ll   980  rm -rf transportz.zip   981  ll   982  cp -rvf transportz/* .   983  rm -rf transportz/ packer build aws.json now to n.virginia region  go to ami launch image  go to ec2 dashboard  launch instance  all traffic anywhere use public ip of that with 8080 and see website' vim   moo.json {        "builders": [            {            "type": "amazon-ebs",            "access_key": "AGQ",            "secret_key": "K1aurid",            "region": "us-east-1",         ...