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 'New User'
end
file 'randomfile' do
group 'root'
user 'ec2-user'
mode '0770'
end
Write a recipe to updates the access (atime) and file modification (mtime) times for a file.
file 'amtime' 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 'Execute' do
user 'root'
code <<-EOF
wget https://download.java.net/java/GA/jdk19/877d6127e982470ba2a7faa31cc93d04/36/GPL/openjdk-19_linux-x64_bin.tar.gz
tar -xf openjdk-19_linux-x64_bin.tar.gz -C /opt/
export JAVA_HOME="/usr/bin"
export PATH=$JAVA_HOME/bin:$PATH
source /etc/profile
EOF
end
Write a chef recipe to execute one sample bash script.
bash "Execute" do
user "root"
code <<-EOF
ll -a
EOF
end
Write a chef recipe to Create a directory
directory 'new_dir'
Write a chef recipe to install git.
package 'git'
Write a chef recipe to clone git repo https://github.com/scmgalaxy/chef-repo
package 'git'
git '/home/centos/chef/' do
repository "https://github.com/scmgalaxy/chef-repo.git"
revision 'master'
action :sync
end
Write a chef recipe to create group and use in linux.
group "devops"
user "new_user" do
group "devops"
end
Write a chef recipe to Download a file from a URL. Note – https://raw.githubusercontent.com/scmgalaxy/chef-repo/master/README.md
directory "downloads"
remote_file "downloads/README.md" do
source "https://raw.githubusercontent.com/scmgalaxy/chef-repo/master/README.md"
end
Write a chef recipe to create a new user and password in the Nodes automatically?
user 'new_user' do
comment 'New user'
shell '/bin/bash'
password '$1324'
end
Write a chef recipe to add= a message to a log file.
log 'message' do
message 'Adding message to the log'
level :info
end
Top comments (0)