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

  • Learning DevOps
  • Mikael Krief
  • 306字
  • 2021-06-24 12:32:02

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.
主站蜘蛛池模板: 塔城市| 莒南县| 洪江市| 古浪县| 敦煌市| 遵义市| 会东县| 盈江县| 当阳市| 莱州市| 阿瓦提县| 浪卡子县| 泗水县| 临颍县| 凌海市| 会泽县| 福安市| 高阳县| 弋阳县| 宜川县| 清徐县| 金乡县| 景泰县| 涞源县| 朝阳县| 庆云县| 正阳县| 和顺县| 庄河市| 东阳市| 仪陇县| 松桃| 龙井市| 沙田区| 邯郸市| 五寨县| 鄂托克旗| 德清县| 奈曼旗| 同江市| 桦甸市|