官术网_书友最值得收藏!

Server configuration

This step concerns the configuration of virtual machines, such as the configuration of hardening, directories, disk mounting, network configuration (firewall, proxy, and so on), and middleware installation.

There are different configuration tools, such as Ansible, PowerShell DSC, Chef, Puppet, and SaltStack. Of course, there are many more, but, in this book, we will look at, in detail, the use of Ansible to configure a virtual machine.

To optimize server provisioning and configuration times, it is also possible to create and use server models, also called images, that contain all of the configuration (hardening, middleware, and so on) of the servers. It will be during the provisioning of the server that we will indicate the template to use, and hence, we will have, in a few minutes, a configured server ready to be used.

There are also many IaC tools for creating server templates, such as aminator (used by Netflix) or HashiCorp Packer.

Here is an example of Packer file code that creates an Ubuntu image with package updates:

{
"builders": [{
"type": "azure-arm",
"os_type": "Linux",
"image_publisher": "Canonical",
"image_offer": "UbuntuServer",
"image_sku": "16.04-LTS",
"managed_image_resource_group_name": "demoBook",
"managed_image_name": "SampleUbuntuImage",
"location": "West Europe",
"vm_size": "Standard_DS2_v2"
}],
"provisioners": [{
"execute_command": "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'",
"inline": [
"apt-get update",
"apt-get upgrade -y",
"/usr/sbin/waagent -force -deprovision+user && export HISTSIZE=0 && sync"
],
"inline_shebang": "/bin/sh -x",
"type": "shell"
}]
}

This script creates a template image for the Standard_DS2_V2 virtual machine based on the Ubuntu OS (the builders section). Additionally, Packer will update all packages during the creation of the image with the apt-get update command and, after this execution, Packer deprovisions the image to delete all user information (the provisioners section).

The Packer part will be discussed in detail in Chapter 4, Optimizing Infrastructure Deployment with Packer.
主站蜘蛛池模板: 永年县| 昔阳县| 十堰市| 台州市| 孟津县| 榆中县| 石门县| 乌什县| 临澧县| 江津市| 巩义市| 通河县| 碌曲县| 泽普县| 井研县| 瓮安县| 兰坪| 神木县| 霍城县| 澳门| 广西| 溧水县| 皮山县| 祁连县| 彩票| 通渭县| 交口县| 上饶县| 衡山县| 徐州市| 雷波县| 平阴县| 平湖市| 海原县| 惠水县| 蓬溪县| 封丘县| 内江市| 丹江口市| 永康市| 易门县|