-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcloud_init_chef.txt
More file actions
39 lines (34 loc) · 1.03 KB
/
cloud_init_chef.txt
File metadata and controls
39 lines (34 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
mkdir -p /data/installers
mkdir -p /data/cookbooks
cd /data/installers/
rm -rf /data/cookbooks/*
outfile='/var/log/userdata.out'
# Install wget
if [ ! -f /bin/wget ] ; then
yum install wget -y >> $outfile
fi
# Install Chef client v14
if [ ! -f /bin/chef-client ] ; then
echo "Installing chef client" >> $outfile
wget https://packages.chef.io/files/stable/chef/14.3.37/el/7/chef-14.3.37-1.el7.x86_64.rpm >> $outfile
rpm -i chef-14*.rpm >> $outfile
fi
# Install git
if [ ! -f /bin/git ] ; then
yum install git -y >> $outfile
fi
# Clone rpm creation repo
cd /data/cookbooks
echo "Creating dummmy rpm" >> $outfile
git clone https://github.com/chefgs/create_dummy_rpm.git >> $outfile
cd create_dummy_rpm
chmod +x create_rpm.sh
./create_rpm.sh spec_file/my-monitoring-agent.spec >> $outfile
# Clone Chef cookbook repo
cd /data/cookbooks
echo "Cookbook Repo cloning" >> $outfile
git clone https://github.com/chefgs/cloud_init.git >> $outfile
echo "Executing chef-client" >> $outfile
cd /data
chef-client -z -o cloud_init >> /var/log/chefrun.out