Information Technology Reference
In-Depth Information
# omnibus_package is remote (i.e., a URL) let's download it
remote_file package_local_path
ddo
source package_url
end
end
package package_local_path
# reconfigure the installation
execute
'private-chef-ctl reconfigure'
Run
kitchen converge
to install Enterprise Chef Server, and use
kitchen login
to verify
that the
private-chef
package was installed. The
kitchen converge
will take some time,
perhaps as long as 10 to 15 minutes, as it needs to download an 800-MB installation package
for Enterprise Chef:
$
kitchen converge default-centos65
$
kitchen login default-centos65
[vagrant@default-centos65 ~]$
rpm -q private-chef
private-chef-11.1.8-1.el6.x86_64
[vagrant@default-centos65 ~]$
exit
logout
Connection to 127.0.0.1 closed.
Introducing Idempotence
Although the recipe we created in
Example 9-3
is a good first attempt, it is not
idempotent
.
When Chef code is
idempotent
, it can run multiple times on the same system and the results
will always be identical, without producing unintended side effects. All Chef default re-
sources are guaranteed to be
idempotent
with the exception of the
execute
resource.
execute
resources are generally not idempotent, because most command-line utilities can be
run only once. They assume that a human being is interacting with the system and under-
stands the state of the system. For example, assuming the file
/learningchef/file1.txt
exists,
the following
mv
command will work the first time it is run, but it will fail the second time:
$
mv /learningchef/file1.txt /file1.txt