Debug School

ayyappa
ayyappa

Posted on

AyyappaReddy - Chef Assignment (Day 2)

Write a recipe to create a file which should be owned by group called “root”, user “ec2-user” and permission executable.

`user 'ec2-user' do
password 'admin$123'
end

file 'admin1.txt' do
content "This is a admin file."
mode '0755'
owner 'ec2-user'
group 'root'
end`

Write a recipe to updates the access (atime) and file modification (mtime) times for a file.

file '/var/www/customers/public_html/index.php' do
content 'This is a placeholder for the home page.'
mode '0755'
owner 'web_admin'
group 'web_admin'
end

Write a recipe to download the java tar ball, extract it under /opt/ and set JAVA_HOME using bash resources. Note – https://jdk.java.net/archive/

file 'javainstall.sh' do
content 'wget https://download.java.net/java/GA/jdk18.0.2/f6ad4b4450fd4d298113270ec84f30ee/9/GPL/openjdk-18.0.2_linux-aarch64_bin.tar.gz
gunzip openjdk-18.0.2_linux-aarch64_bin.tar.gz
tar -xvf openjdk-18.0.2_linux-aarch64_bin.tar -C /opt/
export JAVA_HOME=/opt/jdk-18.0.2'
mode '0755'
owner 'root'
group 'root'
end
execute 'Execute my script' do
user 'root'
cwd '/root/chefday1'
command './javainstall.sh'
end

Write a chef recipe to execute one sample bash script.

file 'shellscript.sh' do
content '
ls -ltr;
pwd'
mode '0755'
owner 'root'
group 'root'
end
execute 'Execute my script' do
user 'root'
cwd '/root/chefday1'
command './shellscript.sh'
end

Write a chef recipe to Create a directory

directory '/root/vishesh/day2/new_dir' do
owner 'ec2-user'
group 'root'
mode '0755'
action :create
end

Write a chef recipe to install git.

`package 'git' do
action :install
end

git 'gitclone' do
remote 'origin'
repository 'https://github.com/kubernetes/kubectl.git'
user 'root'
action :sync

Top comments (0)