February 2020
M T W T F S S
« Jan    
 12
3456789
10111213141516
17181920212223
242526272829  

Categories

WordPress Quotes

What we plant in the soil of contemplation, we shall reap in the harvest of action.
Meister Eckhart
February 2020
M T W T F S S
« Jan    
 12
3456789
10111213141516
17181920212223
242526272829  

Short Cuts

2012 SERVER (64)
2016 windows (9)
AIX (13)
Amazon (40)
Ansibile (19)
Apache (135)
Asterisk (2)
cassandra (2)
Centos (211)
Centos RHEL 7 (268)
chef (3)
cloud (2)
cluster (3)
Coherence (1)
DB2 (5)
DISK (25)
DNS (9)
Docker (30)
Eassy (11)
ELKS (1)
EXCHANGE (3)
Fedora (6)
ftp (5)
GIT (3)
GOD (2)
Grub (1)
Hacking (10)
Hadoop (6)
health (2)
horoscope (23)
Hyper-V (10)
IIS (15)
IPTABLES (15)
JAVA (7)
JBOSS (32)
jenkins (1)
Kubernetes (7)
Ldap (5)
Linux (188)
Linux Commands (166)
Load balancer (5)
mariadb (14)
Mongodb (4)
MQ Server (24)
MYSQL (84)
Nagios (5)
NaturalOil (13)
Nginx (35)
Ngix (1)
openldap (1)
Openstack (6)
Oracle (35)
Perl (3)
Postfix (19)
Postgresql (1)
PowerShell (2)
Python (3)
qmail (36)
Redis (12)
RHCE (28)
SCALEIO (1)
Security on Centos (29)
SFTP (1)
Shell (64)
Solaris (58)
Sql Server 2012 (4)
squid (3)
SSH (10)
SSL (14)
Storage (1)
swap (3)
TIPS on Linux (28)
tomcat (62)
Ubuntu (1)
Uncategorized (30)
Veritas (2)
vfabric (1)
VMware (28)
Weblogic (38)
Websphere (71)
Windows (19)
Windows Software (2)
wordpress (1)
ZIMBRA (17)

WP Cumulus Flash tag cloud by Roy Tanck requires Flash Player 9 or better.

Who's Online

18 visitors online now
7 guests, 11 bots, 0 members

Hit Counter provided by dental implants orange county

chef beginner

INSPEC.IO
user ‘test’ do
comment ‘test user’
uid ’89’
gid ’89’
home ‘/home/random’
shell ‘/bin/bash’
action :create
password ‘$1$JJsvHslasdfjVEroftprNn4JHtDi’
end
user ‘test’ do
comment ‘test user’
uid ’89’
gid ’89’
home ‘/home/test’
shell ‘/bin/bash’
action :create
password ‘$1$/IoJI4pW$rVC197lCpPyDdkD7RxiRG/’
end
user ‘test’ do
comment ‘test user’
uid ’89’
gid ’89’
home ‘/home/test’
shell ‘/bin/bash’
action :modify
password ‘$1$/IoJI4pW$rVC197lCpPyDdkD7RxiRG/’
end

package ‘pqr’ do
action :remove
end

package ‘tree’ do
action :install
end

for p in [ “elinks”, “wget”, “lynx”, “vim”, “ant” ] do
package p do
action [:install]
end
end

package git
group “test1” do
gid 3000
end
user “test1” do
uid “3000”
shell “/sbin/nologin”
home “/home/test”
gid “3000”
password ‘$1$/IoJI4pW$rVC197lCpPyDdkD7RxiRG/’
end

file ‘/etc/motd’ do
content ‘

===================================
This server is a property of visa

===================================

mode “0644”
end
root@ws:/var/chef/cookbooks/useradd/recipes# /opt/chefdk/embedded/bin/ruby -c default.rb
Syntax OK
root@ws:/var/chef/cookbooks/useradd/recipes#

run on local mode

chef-client -z | –local-mode

chef-client –local-mode –why-run

chef-client –local-mode

chef-client –local -o recipe
chef-client -z -l info test.rb

I understand Chef conditional execution.

I’d like to do some conditional execution based on whether or not a database exists in Postgresql

So here’s my example

execute “add_db” do
cwd “/tmp”
user “dbuser”
command “createdb -T template_postgis mydb”
not_if ‘psql –list|grep mydb’
end
execute “touch /home/#{user}/monkeypants” do
user “monkey”
group “monkey”
cwd “/home/monkey”
not_if “check_command”, :cwd => “/home/monkey” , :user => “monkey”, :group => “monkey”
end
log “Welcome to Chef, #{node[“starter_name”]}!” do
level :info
end

file ‘/etc/my_first_file’ do
content ‘This is my first file creation using chef server’
end

file ‘/etc/my_second_file’ do
content ‘My Second file’
end
ignore_failure true

Full control

In case this happens to a resource you control, you have the wonderful ignore_failure attribute to modify this behavior. Adding it to e.g. a service, will enable Chef to continue a run, even if this resource is failing.

service “apache” do
action :enable
ignore_failure true
end

how to create a cookbook
chef
mkdir cookbooks

Usage: chef generate GENERATOR [options]

Available generators:
app Generate an application repo
cookbook Generate a single cookbook
recipe Generate a new recipe
attribute Generate an attributes file
template Generate a file template
file Generate a cookbook file
lwrp Generate a lightweight resource/provider
repo Generate a Chef code repository
policyfile Generate a Policyfile for use with the install/push commands
generator Copy ChefDK’s generator cookbook so you can customize it
build-cookbook Generate a build cookbook for use with Delivery
knife cookbook create nginx
** Creating cookbook nginx
** Creating README for cookbook: nginx
** Creating CHANGELOG for cookbook: nginx
** Creating metadata for cookbook: nginx
chef generate cookbook cookbooks/nginx

root@ws:~# chef generate cookbook cookbooks/nginx
Generating cookbook nginx
– Ensuring correct cookbook file content
– Committing cookbook files to git
– Ensuring delivery configuration
– Ensuring correct delivery build cookbook content
– Adding delivery configuration to feature branch
– Adding build cookbook to feature branch
– Merging delivery content feature branch to master

Your cookbook is ready. Type `cd cookbooks/nginx` to enter it.

There are several commands you can run to get started locally developing and testing your cookbook.
Type `delivery local –help` to see a full list.

Why not start by writing a test? Tests for the default recipe are stored at:

test/recipes/default_test.rb

If you’d prefer to dive right in, the default recipe can be found at:

recipes/default.rb

version cotrol

Berksfile README.md chefignore metadata.rb recipes spec test
root@ws:~/cookbooks/nginx# cat metadata.rb
name ‘nginx’
maintainer ‘The Authors’
maintainer_email ‘you@example.com’
license ‘all_rights’
description ‘Installs/Configures nginx’
long_description ‘Installs/Configures nginx’
version ‘0.1.0’
cookbooks
|_nginx
|_recipes
|_default
|_test.rb

execute ‘apt-get update’ do
action :run
end

package ‘nginx’ do
action :install
end

service ‘nginx’ do
action [ :enable, :start ]
end

service ‘nginx’ do
supports status: true, restart: true, reload: true
action :enable
end
service ‘apache’ do
supports :restart => true, :reload => true
action :enable
end
service “nginx” do
supports :restart => true, :start => true, :stop => true, :reload => true
action :nothing
end

template “nginx” do
path “/etc/init.d/nginx”
source “nginx.erb”
owner “root”
group “root”
mode “0755”
notifies :enable, “service[nginx]”
notifies :start, “service[nginx]”
end

cookbook_file “/usr/share/nginx/html/index.html” do
source “index.html”
mode “0644”
end
cd ~/chef-repo/cookbooks/nginx/files/default

nano index.html

<html>
<head>
<title>Hello there</title>
</head>
<body>
<h1>This is a Mohan test</h1>
<p>Please Mohan work!</p>
</body>
</html>
excute ‘service nginx stop ‘ do
not_if ‘service nginx status’
end

chef-client -z –runlist “recipe[nginx::install],recipe[nginx::service]”

chef-client -z –runlist “recipe[nginx::install]”
install.rb

execute ‘apt-get update’ do
end

package ‘nginx’ do
action :install
end
service.rb

service ‘nginx’ do
action :start
end

execute ‘my own service start description’ do
command ‘service nginx start’
not_if ‘service nginx status’
end
config.rb

cookbook_file ‘/etc/nginx/nginx.conf’ do
source ‘nginx.conf’
mode ‘0644’
action :create
notifies :restart, ‘service[nginx]’
end
cookbook_file ‘/usr/share/nginx/html/index.html’ do
source ‘index.html’
mode ‘0644’
action :create
end

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

  

  

  

Blue Captcha Image
Refresh

*

Protected by WP Anti Spam