-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloud_init_ansible.txt
38 lines (33 loc) · 1004 Bytes
/
cloud_init_ansible.txt
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
#!/bin/bash
mkdir -p /data/installers
mkdir -p /data/ansible
cd /data/installers/
rm -rf /data/ansible/*
outfile='/var/log/userdata.out'
# Install wget
if [ ! -f /bin/wget ] ; then
yum install wget -y >> $outfile
fi
# Install Ansible
if [ ! -f /bin/ansible ] ; then
echo "Installing Ansible" >> $outfile
yum install ansible -y >> $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 Ansible repo
cd /data/ansible
echo "Playbook Repo cloning" >> $outfile
git clone https://github.com/chefgs/ansible_playbooks.git >> $outfile
echo "Executing Playbook" >> $outfile
cd /data/ansible/ansible_playbooks/cloud_init_playbook/
ansible-playbook playbook.yml -i ansible/hosts.ini >> /var/log/ansiblerun.out