Debug School

Komal Samleti
Komal Samleti

Posted on

chef Assignment 1 by Komal S.

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
comment 'A ec2-user user'
password 'ec2-user'
end

file 'assignment1' do
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 '/home/centos/assignment1' do
action :touch
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/
`bash 'extract_module' do
code <<-EOH
mkdir -p /opt/
wget https://download.java.net/java/GA/jdk19/877d6127e982470ba2a7faa31cc93d04/36/GPL/openjdk-19_linux-x64_bin.tar.gz
tar xzf openjdk-19_linux-x64_bin.tar.gz -C /opt/
export JAVA_HOME = /opt/jdk-19/bin
EOH

end`

*Write a chef recipe to execiute one sample bash script.
*

execute 'Execute my script' do
user 'root'
cwd '/home/centos'
command './sample.sh'
end

Write a chef recipe to Create a directory
directory '/etc/test1' do
owner 'root'
group 'root'
mode '0755'
action :create
end

Top comments (0)