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 'Test$123'
end
file 'test1.txt' do
content "This is a test 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 '<html>This is a placeholder for the home page.</html>'
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/
`script 'install_java' do
interpreter 'bash'
user 'root'
cwd '/tmp'
code <<-EOH
wget https://download.java.net/java/GA/jdk18.0.2/f6ad4b4450fd4d298113270ec84f30ee/9/GPL/openjdk-18.0.2_linux-x64_bin.tar.gz
cp -pr openjdk-18.0.2_linux-x64_bin.tar.gz /opt/openjdk-18.0.2_linux-x64_bin.tar.gz
cd /opt
tar -zxf openjdk-18.0.2_linux-x64_bin.tar.gz
cd jdk-18.0.2
./configure
make
make install
EOH
end
bash 'set_JAVA_HOME' do
environment 'JAVA_HOME' => '/usr/lib/java/jdk1.7/home'
end`
Write a chef recipe to execute one sample bash script.
bash 'Execute my script' do
user 'root'
cwd '/root/vishesh/day2'
code <<-EOH
/root/vishesh/day2/numbers.sh
EOH
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/scmgalaxy/helloworld-java-maven'
user 'root'
action :sync
end`
Write a chef recipe to create group and user in Linux.
group 'chef_group' do
gid '2000'
action :create
end
user 'test_user' do
uid '2000'
gid '2000'
action :create
end
Top comments (0)