Skip to content

Commit 55371b3

Browse files
committed
chef-solo: added template example
1 parent 1563e7c commit 55371b3

File tree

10 files changed

+241
-186
lines changed

10 files changed

+241
-186
lines changed

config-automation/chef/vagrant_called/cookbooks/cookbook0/recipes/default.rb

+14-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
File.open("/tmp/cookbook0_default.tmp", 'w') do |f|
2-
1+
File.open(File.join(Dir.tmpdir, "cookbook0_default.tmp"), 'w') do |f|
32

43
node[:cookbook0][:a] == "b" or raise
54
node[:cookbook0][:override] == "d" or raise
@@ -18,7 +17,7 @@
1817

1918
##file
2019

21-
file "/tmp/cookbook0_default_file.tmp" do
20+
file File.join(Dir.tmpdir, "cookbook0_default_file.tmp") do
2221
content Time.now.to_s
2322
#owner "root" # root is the default user
2423
#group "root"
@@ -28,11 +27,22 @@
2827

2928
# Double create overwrites the files:
3029

31-
file "/tmp/cookbook0_default_file.tmp" do
30+
file File.join(Dir.tmpdir, "cookbook0_default_file.tmp") do
3231
content "second time: " + Time.now.to_s
3332
mode "0666"
3433
end
3534

35+
##template
36+
37+
# Generates a file from an erb template located under `templates/default`.
38+
39+
# Typically used for config files which vary from installation to isntallation.
40+
41+
template File.join(Dir.tmpdir, "cookbook0_template.tmp") do
42+
source "cookbook0_template.tmp.erb"
43+
variables({:a=> '0', :b=> '1'})
44+
end
45+
3646
##platform detection
3747

3848
# `node[:platform]` the following contains a string which identifies the current platform.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<%= @a %>
2+
<%= @b %>
3+
<%= node[:cookbook0][:a] %>

game.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
Most famous dangeon crawler.
66

7+
Save is only pause: no return from death.
8+
9+
Many things kill you for totally unpredictable reasons.
10+
711
##fortune
812

913
Tells you fortune to stdout!
@@ -88,13 +92,13 @@ Count primes:
8892

8993
###robots
9094

91-
Simple, fun, but too much luck.
95+
Very simple, fun, but too much luck.
9296

9397
Play:
9498

9599
robots
96100

97-
play with better settings:
101+
Play with better settings:
98102

99103
alias robots="robots -ta`for i in {1..10000}; do echo -n n; done`"
100104

@@ -126,7 +130,7 @@ Nethack predecessor.
126130

127131
Multiplayer shooter.
128132

129-
Looks *very* promising, but multiplayer only...
133+
Looks *very* promising, but multiplayer only, and no online mode.
130134

131135
##gnugo
132136

grep.md

+3-5
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,17 @@ useful if you only want the exit status
8484

8585
##application
8686

87-
append line to file
88-
if it is not there already
87+
Append line to file only if it is not there already:
8988

9089
f=""
9190
l=""
9291
grep -q "^$l$" "$f" || echo "$l" >> "$f"
9392

94-
very useful for files that have unordered
95-
sets of things separated by newlines
93+
Very useful for files that have unordered sets of things separated by newlines.
9694

9795
#-c
9896

99-
count how many lines match
97+
Count how many lines match
10098

10199
echo $'a\na' | grep -c a
102100

index.md

+37-34
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
Linux in informal terms can be either a computer system that:
22

3-
- a computer system which complies to the [linux standar base (lsb)](lsb)
4-
which is the main standard maintained by the [linux foundation][]
3+
- a computer system which complies to the [linux standar base (LSB)](lsb)
4+
which is the main standard maintained by the [Linux foundation][]
55

6-
- uses the linux kernel. TODO is this specified by the lsb? where?
6+
- uses the Linux kernel. TODO is this specified by the LSB? where?
77

8-
The lsb specifies the minimum intefaces every linux system must offer.
8+
The LSB specifies the minimum intefaces every linux system must offer.
99

1010
The central component of the linux operating system is the linux kernel,
1111
released in 1991 by Linus Trovalds, however much of its core user space
12-
software comes from the gnu project. For this reason linux systems
12+
software comes from the GNU project. For this reason linux systems
1313
may also be called gnu/linux.
1414

1515
#sources
@@ -104,7 +104,7 @@ so it makes no sense to save a file to the CD.
104104

105105
You could however mount your hard disk, and write to it after you booted from the CD.
106106

107-
You will need a free partition for the installation. Mo
107+
You will need a free partition for the installation.
108108

109109
###usb install
110110

@@ -114,28 +114,28 @@ Some installers even allow you to reserve space on the USB for permanent storage
114114
so that you can use your OS from the USB just as if it were an small and fast HD.
115115

116116
If however you are already on Linux, you will probably have to destroy all USB information,
117-
because the ISO image has to be the very first thing on your usb, therfore erasing essential
118-
filesystem structures such as the main boot record partition table.
117+
because the ISO image has to be the very first thing on your USB, therefore erasing essential
118+
filesystem structures such as the main boot record partition table of the USB.
119119

120120
Of course, you can always recreate a filesystem in your USB and use it
121-
as a storage device once you are done with the USB.
121+
as a storage device once you are done with it.
122122

123123
To install images on a USB you can do:
124124

125-
dd bs=4M if=/path/to/iso.iso of=/dev/sdX
125+
sudo dd bs=4M if=/path/to/iso.iso of=/dev/sdX
126126

127127
Where `/dev/sdX` is the mount point of the USB.
128128

129129
This will erase all data on the USB!
130130

131-
- `/dev/sdX` is the block device for the USB, and it can be found with:
131+
`/dev/sdX` is the block device for the USB, and it can be found with:
132132

133-
sudo lsblk -f
133+
sudo lsblk -f
134134

135-
The usb must not be mounted (`lsblk` shows no mountpoint).
135+
The USB must not be mounted (`lsblk` shows no mountpoint).
136136

137-
*Don't* write to the first partition `/dev/sdX1`, since what we want is to write
138-
to the start of the device, not to the start of its first partition!
137+
*Don't* write to the first partition `/dev/sdX1`, since what we want is to write
138+
to the start of the device, not to the start of its first partition!
139139

140140
###bootloader problems
141141

@@ -228,45 +228,48 @@ notable certified systems include:
228228

229229
- Red Hat Enterprise Linux 6.0
230230

231-
#linux and gnu
231+
#gnu
232232

233-
[linux and gnu][]
234-
235-
the user space programs of linux are mostly inherited from the *gnu project*
233+
The user space programs of most Linux distributions are mostly inherited from the *GNU project*
236234
which was created in 1983 by Richard Stallman.
237235

238-
for example, the following central components originate from gnu:
236+
For example, the following central components originate from GNU:
239237

240238
- gcc
241239
- glibc
242240
- bash
243241

244-
it seems that the gnu project is not officially called like that anymore,
245-
and has transformed into the *free software foundation* (fsf) also founded by Stallman
242+
It seems that the GNU project is not officially called like that anymore,
243+
and has transformed into the *free software foundation* (FSF) also founded by Stallman.
246244
TODO check
247245

248-
amongst the projects of the fsf is the *gnu operating system*.
249-
they are also active in legal causes and activism for free software
246+
Amongst the projects of the fsf is the *gnu operating system*.
247+
they are also active in legal causes and activism for free software.
250248

251-
the gnu operating system is developping its own kernel called *HUD*,
249+
The GNU operating system is developping its own kernel called *HUD*,
252250
but the own project states that it is not yet ready for broad usage
253251

254-
the fsf insists on caling what most people call linux as GNU/linux,
252+
The fsf insists on caling what most people call linux as GNU/linux,
255253
which sounds quite reasonable considering they developed a great part of
256-
the userspace core
254+
the userspace core.
257255

258-
the gnu software foundation is the creator and current maintainer
256+
The GNU software foundation is the creator and current maintainer
259257
of the GPL licence, and mostly uses that licence for its software and
260-
is the main enforcer of its infringements
258+
is the main enforcer of its infringements.
259+
260+
##gnu alternatives
261+
262+
Some notable alternatives to the GNU tools:
261263

262-
#lsb and posix
264+
#POSIX
263265

264-
lsb is already highly posix compliant, and it states that it is on of its
265-
long term goals meant to become fully posix compatible
266+
LSB is already highly POSIX compliant, and it states that it is on of its
267+
long term goals meant to become fully POSIX compatible
266268

267-
incompatibility are being listed for future resolution
269+
Incompatibilities are being listed for future resolution.
268270

269-
there some posix requirements that the linux kernel simply does not
271+
There a few POSIX requirements that the Linux kernel explicitly does not implement
272+
because it considers them impossible to implement efficiently.
270273

271274
#fhs
272275

net/index.md

+5
Original file line numberDiff line numberDiff line change
@@ -1193,6 +1193,11 @@ and to check its status:
11931193

11941194
sudo service ssh status
11951195

1196+
The default log file for the server is: `/var/log/auth.log`, which is shared by other
1197+
utilities such as `sudo`.
1198+
If things fail, this is where you should look!
1199+
Try `sudo grep sshd /var/log/auth.log` for the relevant log lines.
1200+
11961201
##client
11971202

11981203
The client connects to a server to give shell access on the server.

sound/index.md

+25-22
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,25 @@ sound and music players, editors and generators
44

55
##cplay
66

7-
cli
7+
CLI
88

9-
has a file browser
9+
Has a file browser.
1010

1111
cplay
1212

1313
#manipulation
1414

1515
##lame
1616

17-
encode, decode and modify mp3
17+
Encode, decode and modify mp3.
1818

19-
increases volume 5x:
19+
Increases volume 5x:
2020

2121
lame --scale 5 a.mp3
2222

2323
##id3tool
2424

25-
get id3 tags info (for mp3 for example)
25+
Get id3 tags info (for mp3 for example):
2626

2727
TITLE="`id3tool "$1" | grep '^Song Title:' | awk '{ for (i=3;i<=NF;i++) { printf $i; printf " " } }'`"
2828
ARTIST="`id3tool "$1" | grep '^Artist:' | awk '{ for (i=2;i<=NF;i++) { printf $i; printf " " } }'`"
@@ -36,41 +36,44 @@ get id3 tags info (for mp3 for example)
3636

3737
###flacon
3838

39-
has gui
39+
GUI.
4040

4141
###shntool
4242

43-
single ape and cue in dir, flac output, formatted as number, author, track
43+
Single APE and CUE in dir, FLAC output, formatted as number, author, track
4444

4545
shntool split -f *.cue -o flac *.ape -t '%n - %p - %t'
4646

4747
##sox
4848

49-
record, play and modify files cli
49+
Set of utilities record, play and modify files via CLI.
5050

51-
interactive front end for libSoX
51+
Interactive front end for libSoX.
5252

53-
must install available formats separatelly
53+
Must install available formats separatelly.
5454

55-
record from microphone into `a.wav` file:
55+
Record from microphone into `a.wav` file:
5656

5757
rec a.wav
5858

59-
`ctrl+c` : stop recording
59+
`ctrl+c` to stop recording.
6060

61-
plays `a.wav` file:
61+
Plays `a.wav` file:
6262

6363
play a.wav
6464

65-
terminates when over
65+
Terminates when over. Good option to play an alarm signal after a very long command:
66+
67+
sleep 5 && play long-sound.wav
6668

6769
#alsa
6870

69-
Advanced Linus Sound API.
71+
Advanced Linux Sound API.
7072

71-
Replaced OSS in 2008 when it when proprietary. OSS came back to open source, but it lost much momentume back to open source, but it lost much momentum.
73+
Replaced OSS in 2008 when OSS when went proprietary.
74+
OSS came back to open source, but it lost much momentum.
7275

73-
The kernel soud subsystem is called ALSA.
76+
The kernel sound subsystem is called ALSA.
7477

7578
There are a few tools that interact with it.
7679

@@ -80,7 +83,7 @@ ncurses interface to view/control sound parameters
8083

8184
alsamixer
8285

83-
commands:
86+
Commands:
8487

8588
- left/right : change active parameter
8689
- up/down : change active parameter value
@@ -103,7 +106,7 @@ Unmute sound:
103106

104107
##aplay
105108

106-
Command line tool that takes numeric input from stdin and generate sound!
109+
Command line tool that takes numeric input from stdin and generate sound.
107110

108111
#pulseaudio
109112

@@ -117,10 +120,10 @@ Command line control to pulseaudio.
117120

118121
###cli
119122

120-
rip:
123+
Rip from dvd:
121124

122125
abcde
123126

124-
automatically starts ripping correctly on most systems!!
127+
Automatically finds right configurations on most systems.
125128

126-
creates dir in cur dir and saves rip out as `.ogg` in it
129+
Creates dir in cur dir and saves rip out as `.ogg` in it.

0 commit comments

Comments
 (0)