- Install docker with the following command:
yum install docker
systemctl start docker - Then we need to install the kitchen-docker ruby gem.
chef gem install kitchen-docker - Create a cookbook:
chef generate cookbook my_cookbook - Edit the .kitchen.yml file in the generated cookbook.
Change the driver name from vagrant to docker and delete the line
- name: centos-7
Save and close. - Then execute kitchen converge. This command will create a docker container for us and put all the settings in place.
The output will be something as follows:
Synchronizing Cookbooks:
- my_cookbook (0.1.0)
Installing Cookbook Gems:
Compiling Cookbooks...
Converging 0 resourcesRunning handlers:
Running handlers complete
Chef Client finished, 0/0 resources updated in 18 seconds
Finished converging <default-ubuntu-1604> (7m3.52s). - Then run kitchen list
The output will be something as follows:
Instance Driver Provisioner Verifier Transport Last Action Last Error
default-ubuntu-1604 Docker ChefZero Inspec Ssh Converged <None> - Now we need to verify whether the test was successful or not. Execute
kitchen verify
-----> Starting Kitchen (v1.17.0)
-----> Setting up <default-ubuntu-1604>...
Finished setting up <default-ubuntu-1604> (0m0.00s).
-----> Verifying <default-ubuntu-1604>...
Loaded tests from test/smoke/default
Profile: tests from test/smoke/default
Version: (not specified)
Target: ssh://kitchen@localhost:32768
User root
↺
Port 80
↺
Test Summary: 0 successful, 0 failures, 2 skipped
Finished verifying <default-ubuntu-1604> (0m3.62s).
-----> Kitchen is finished. (0m6.58s) - Edit the file vi test/smoke/default/default_test.rb
Add the following lines to it:
describe package('cowsay') do
it {should be_installed }
end - Then run kitchen verify. This test should return failed:
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: 1 actions failed.
>>>>>> Verify failed on instance <default-ubuntu-1604>. Please see .kitchen/logs/default-ubuntu-1604.log for more details
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration - Edit the following file vi recipes/default.rb
Add the line package 'cowsay'
Then execute kitchen converge and then kitchen test.
The output should be something like
System Package
✔ cowsay should be installed
Test Summary: 1 successful, 0 failures, 1 skipped
Terraform is a tool for building, changing, and versioning infrastructure safely and efficiently. Terraform can manage existing and popular service providers as well as custom in-house solutions. Configuration files describe to Terraform the components needed to run a single application or your entire datacenter. Terraform generates an execution plan describing what it will do to reach the desired state, and then executes it to build the described infrastructure. As the configuration changes, Terraform is able to determine what changed and create incremental execution plans which can be applied. The infrastructure Terraform can manage includes low-level components such as compute instances, storage, and networking, as well as high-level components such as DNS entries, SaaS features, etc. The key features of Terraform are: Infrastructure as Code : Infrastructure is described using a high-level configuration syntax. This allows a blueprint of your datacenter to be versioned and...
Comments
Post a Comment