Debug School

Nikesh Thakre
Nikesh Thakre

Posted on

Nikesh Thakre- Chef Day2 Assignments

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

file '/home/centos/nikesh.sh' 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/temp.txt' do
content "TEST MESSAGE"
action :create
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 'java installation' do
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
environment JAVA_HOME="/home/centos/openjdk-19_linux-x64_bin/java"
end

Write a chef recipe to execiute one sample bash script.

`file '/home/centos/nikesh.sh' do
mode '0755'
owner 'ec2-user'
group 'root'
end

execute 'Execute my script' do
command './nikesh.sh'
end`

Working with Chef Attributes
`node.default['web']['file'] = 'temp.txt'
file "#{node['web']['file']}" do

end

log "This is my fist logging message." do
level :info
end`

Top comments (0)