プロビジョニング


プロビジョニングとは

Vagrantfile と Box ファイルで仮想マシンを作成した後にシェルスクリプトや Ansible などの構成管理ツールを使用し、アプリケーションのインストールや各種設定などの処理を行うことです。処理はvagrant upコマンドの一部として動作します。

重要

プロビジョニングの実行はユーザー vagrant が sudo 付きで実行します。


実行タイミング

プロビジョニングは初回のvagrant upコマンドの実行時に動作します。vagrant upコマンドやvagrant reloadコマンドで強制的にプロビジョニングを実行する--provisionオプションがあります。明示的にプロビジョニングを実行しないようにする--no-provisionオプションがあります。常にプロビジョニングを実行する方法もあります。


基本動作

プロビジョニングを指定した Vagrantfile です。 Linux コマンドを実行するよう設定しました。網掛け部分がプロビジョニングに関係する部分です。

$script = <<-'SCRIPT'
echo hello, world
SCRIPT

Vagrant.configure("2") do |config|
  config.vm.box = "centos/7"
  config.vm.network "public_network", mac: "080027000001", ip: "192.168.10.1"
  config.vm.hostname = "node1"
  config.vm.provider "virtualbox" do |vb|
    vb.gui = true
    vb.name = "sample-vm"
    vb.memory = "4096"
    vb.cpus = 2
    vb.customize [
      "modifyvm", :id,
      "--ioapic", "on",
      "--graphicscontroller", "vmsvga"
    ]
  end
  config.vm.provision "shell", inline: $script
end

仮想マシンが存在しない状態でvagrant upvagrant haltvagrant upvagrant haltを実行した結果です。

PS C:\vagrant\my_centos> vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'centos/7'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'centos/7' version '1905.1' is up to date...
==> default: Setting the name of the VM: sample-vm
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: bridged
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default:
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default:
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: No guest additions were detected on the base box for this VM! Guest
    default: additions are required for forwarded ports, shared folders, host only
    default: networking, and more. If SSH fails on this machine, please install
    default: the guest additions and repackage the box to continue.
    default:
    default: This is not an error message; everything may continue to work properly,
    default: in which case you may ignore this message.
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Rsyncing folder: /cygdrive/c/vagrant/my_centos/ => /vagrant
==> default: Running provisioner: shell...
    default: Running: inline script
    default: hello, world
PS C:\vagrant\my_centos>
PS C:\vagrant\my_centos> vagrant halt
==> default: Attempting graceful shutdown of VM...
PS C:\vagrant\my_centos>
PS C:\vagrant\my_centos> vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'centos/7' version '1905.1' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: bridged
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Connection aborted. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: No guest additions were detected on the base box for this VM! Guest
    default: additions are required for forwarded ports, shared folders, host only
    default: networking, and more. If SSH fails on this machine, please install
    default: the guest additions and repackage the box to continue.
    default:
    default: This is not an error message; everything may continue to work properly,
    default: in which case you may ignore this message.
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Rsyncing folder: /cygdrive/c/vagrant/my_centos/ => /vagrant
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.
PS C:\vagrant\my_centos>
PS C:\vagrant\my_centos> vagrant halt
==> default: Attempting graceful shutdown of VM...
PS C:\vagrant\my_centos>

vagrant up の実行結果からプロビジョニングの動作確認

初回

プロビジョニングが動作したことがわかります。

==> default: Running provisioner: shell...
    default: Running: inline script
    default: hello, world

2 回目

プロビジョニング済みなので "Machine already provisioned." と表示されています。

==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.

--provision オプション

2 回目のvagrant upコマンドの実行後に--provisionオプションを指定してvagrant upコマンドを実行した結果です。プロビジョニングが動作しました。

PS C:\vagrant\my_centos> vagrant up --provision
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'centos/7' version '1905.1' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: bridged
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: No guest additions were detected on the base box for this VM! Guest
    default: additions are required for forwarded ports, shared folders, host only
    default: networking, and more. If SSH fails on this machine, please install
    default: the guest additions and repackage the box to continue.
    default:
    default: This is not an error message; everything may continue to work properly,
    default: in which case you may ignore this message.
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Rsyncing folder: /cygdrive/c/vagrant/my_centos/ => /vagrant
==> default: Running provisioner: shell...
    default: Running: inline script
    default: hello, world
PS C:\vagrant\my_centos>
PS C:\vagrant\my_centos> vagrant halt
==> default: Attempting graceful shutdown of VM...
PS C:\vagrant\my_centos>

プロビジョニングの常時実行

run: "always"を指定すると常にプロビジョニングが動作します。

$script = <<-'SCRIPT'
echo hello, world
SCRIPT

Vagrant.configure("2") do |config|
  config.vm.box = "centos/7"
  config.vm.network "public_network", mac: "080027000001", ip: "192.168.10.1"
  config.vm.hostname = "node1"
  config.vm.provider "virtualbox" do |vb|
    vb.gui = true
    vb.name = "sample-vm"
    vb.memory = "4096"
    vb.cpus = 2
    vb.customize [
      "modifyvm", :id,
      "--ioapic", "on",
      "--graphicscontroller", "vmsvga"
    ]
  end
  config.vm.provision "shell", inline: $script, run: "always"
end
PS C:\vagrant\my_centos> vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'centos/7' version '1905.1' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: bridged
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: No guest additions were detected on the base box for this VM! Guest
    default: additions are required for forwarded ports, shared folders, host only
    default: networking, and more. If SSH fails on this machine, please install
    default: the guest additions and repackage the box to continue.
    default:
    default: This is not an error message; everything may continue to work properly,
    default: in which case you may ignore this message.
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Rsyncing folder: /cygdrive/c/vagrant/my_centos/ => /vagrant
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.
==> default: Running provisioner: shell...
    default: Running: inline script
    default: hello, world
PS C:\vagrant\my_centos>

シェル

インラインスクリプト

Vagrantfile 内にスクリプトを記述し、それを実行します。

スクリプトと実行部分です。

$script = <<-'SCRIPT'
echo hello, world
echo hello, Vagrant world !
SCRIPT
config.vm.provision "shell", inline: $script

$script 変数に設定した 1 つ以上のコマンドを順番に実行します。

Vagrantfile の全体です。

$script = <<-'SCRIPT'
echo hello, world
echo hello, Vagrant world !
SCRIPT

Vagrant.configure("2") do |config|
  config.vm.box = "centos/7"
  config.vm.network "public_network", mac: "080027000001", ip: "192.168.10.1"
  config.vm.hostname = "node1"
  config.vm.provider "virtualbox" do |vb|
    vb.gui = true
    vb.name = "sample-vm"
    vb.memory = "4096"
    vb.cpus = 2
    vb.customize [
      "modifyvm", :id,
      "--ioapic", "on",
      "--graphicscontroller", "vmsvga"
    ]
  end
  config.vm.provision "shell", inline: $script
end

実行結果です。echoコマンドの実行結果が表示されています。

PS C:\vagrant\my_centos> vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'centos/7'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'centos/7' version '1905.1' is up to date...
==> default: Setting the name of the VM: sample-vm
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: bridged
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default:
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default:
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: No guest additions were detected on the base box for this VM! Guest
    default: additions are required for forwarded ports, shared folders, host only
    default: networking, and more. If SSH fails on this machine, please install
    default: the guest additions and repackage the box to continue.
    default:
    default: This is not an error message; everything may continue to work properly,
    default: in which case you may ignore this message.
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Rsyncing folder: /cygdrive/c/vagrant/my_centos/ => /vagrant
==> default: Running provisioner: shell...
    default: Running: inline script
    default: hello, world
    default: hello, Vagrant world !
PS C:\vagrant\my_centos>

複数のスクリプトの実行もできます。

$script = <<-'SCRIPT'
echo hello, world
SCRIPT
$script2 = <<-'SCRIPT'
echo hello, Vagrant world !
SCRIPT

Vagrant.configure("2") do |config|
  config.vm.box = "centos/7"
  config.vm.network "public_network", mac: "080027000001", ip: "192.168.10.1"
  config.vm.hostname = "node1"
  config.vm.provider "virtualbox" do |vb|
    vb.gui = true
    vb.name = "sample-vm"
    vb.memory = "4096"
    vb.cpus = 2
    vb.customize [
      "modifyvm", :id,
      "--ioapic", "on",
      "--graphicscontroller", "vmsvga"
    ]
  end
  config.vm.provision "shell", inline: $script
  config.vm.provision "shell", inline: $script2
end

実行結果です。config.vm.provisionが 2 回実行されています。

PS C:\vagrant\my_centos> vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'centos/7'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'centos/7' version '1905.1' is up to date...
==> default: Setting the name of the VM: sample-vm
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: bridged
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection aborted. Retrying...
    default:
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default:
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: No guest additions were detected on the base box for this VM! Guest
    default: additions are required for forwarded ports, shared folders, host only
    default: networking, and more. If SSH fails on this machine, please install
    default: the guest additions and repackage the box to continue.
    default:
    default: This is not an error message; everything may continue to work properly,
    default: in which case you may ignore this message.
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Rsyncing folder: /cygdrive/c/vagrant/my_centos/ => /vagrant
==> default: Running provisioner: shell...
    default: Running: inline script
    default: hello, world
==> default: Running provisioner: shell...
    default: Running: inline script
    default: hello, Vagrant world !
PS C:\vagrant\my_centos>

nginx を使用した Web サーバーを構築する Vagrantfile です。

$script = <<-'SCRIPT'
yum -y install epel-release
yum -y install nginx
systemctl start nginx
systemctl enable nginx
systemctl start firewalld
firewall-cmd --add-service=http --permanent
firewall-cmd --reload
SCRIPT

Vagrant.configure("2") do |config|
  config.vm.box = "centos/7"
  config.vm.network "public_network", mac: "080027000001"
  config.vm.hostname = "web-sv"
  config.vm.provider "virtualbox" do |vb|
    vb.gui = true
    vb.name = "nginx"
    vb.memory = "4096"
    vb.cpus = 2
    vb.customize [
      "modifyvm", :id,
      "--ioapic", "on",
      "--graphicscontroller", "vmsvga"
    ]
  end
  config.vm.provision "shell", inline: $script
end

実行結果です。

PS C:\vagrant\my_centos> vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'centos/7'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'centos/7' version '1905.1' is up to date...
==> default: Setting the name of the VM: nginx
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: bridged
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection reset. Retrying...
    default: Warning: Connection aborted. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default:
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default:
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: No guest additions were detected on the base box for this VM! Guest
    default: additions are required for forwarded ports, shared folders, host only
    default: networking, and more. If SSH fails on this machine, please install
    default: the guest additions and repackage the box to continue.
    default:
    default: This is not an error message; everything may continue to work properly,
    default: in which case you may ignore this message.
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Rsyncing folder: /cygdrive/c/vagrant/my_centos/ => /vagrant
==> default: Running provisioner: shell...
    default: Running: inline script
    default: Loaded plugins: fastestmirror
    default: Determining fastest mirrors
    default:  * base: ftp.iij.ad.jp
    default:  * extras: ftp.iij.ad.jp
    default:  * updates: ftp.iij.ad.jp
    default: Resolving Dependencies
    default: --> Running transaction check
    default: ---> Package epel-release.noarch 0:7-11 will be installed
    default: --> Finished Dependency Resolution
    default:
    default: Dependencies Resolved
    default:
    default: ================================================================================
    default:  Package                Arch             Version         Repository        Size
    default: ================================================================================
    default: Installing:
    default:  epel-release           noarch           7-11            extras            15 k
    default:
    default: Transaction Summary
    default: ================================================================================
    default: Install  1 Package
    default: Total download size: 15 k
    default: Installed size: 24 k
    default: Downloading packages:
    default: Public key for epel-release-7-11.noarch.rpm is not installed
    default: warning: /var/cache/yum/x86_64/7/extras/packages/epel-release-7-11.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
    default: Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
    default: Importing GPG key 0xF4A80EB5:
    default:  Userid     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
    default:  Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
    default:  Package    : centos-release-7-6.1810.2.el7.centos.x86_64 (@anaconda)
    default:  From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
    default: Running transaction check
    default: Running transaction test
    default: Transaction test succeeded
    default: Running transaction
    default:   Installing : epel-release-7-11.noarch                                     1/1
    default:
    default:   Verifying  : epel-release-7-11.noarch                                     1/1
    default:
    default:
    default: Installed:
    default:   epel-release.noarch 0:7-11
    default: Complete!
    default: Loaded plugins: fastestmirror
    default: Loading mirror speeds from cached hostfile
    default:  * base: ftp.iij.ad.jp
    default:  * epel: nrt.edge.kernel.org
    default:  * extras: ftp.iij.ad.jp
    default:  * updates: ftp.iij.ad.jp
    default: Resolving Dependencies
    default: --> Running transaction check
    default: ---> Package nginx.x86_64 1:1.16.1-1.el7 will be installed
    default: --> Processing Dependency: nginx-all-modules = 1:1.16.1-1.el7 for package: 1:nginx-1.16.1-1.el7.x86_64
    default: --> Processing Dependency: nginx-filesystem = 1:1.16.1-1.el7 for package: 1:nginx-1.16.1-1.el7.x86_64
    default: --> Processing Dependency: nginx-filesystem for package: 1:nginx-1.16.1-1.el7.x86_64
    default: --> Processing Dependency: redhat-indexhtml for package: 1:nginx-1.16.1-1.el7.x86_64
    default: --> Processing Dependency: system-logos for package: 1:nginx-1.16.1-1.el7.x86_64
    default: --> Processing Dependency: libprofiler.so.0()(64bit) for package: 1:nginx-1.16.1-1.el7.x86_64
    default: --> Running transaction check
    default: ---> Package centos-indexhtml.noarch 0:7-9.el7.centos will be installed
    default: ---> Package centos-logos.noarch 0:70.0.6-3.el7.centos will be installed
    default: ---> Package gperftools-libs.x86_64 0:2.6.1-1.el7 will be installed
    default: ---> Package nginx-all-modules.noarch 1:1.16.1-1.el7 will be installed
    default: --> Processing Dependency: nginx-mod-http-image-filter = 1:1.16.1-1.el7 for package: 1:nginx-all-modules-1.16.1-1.el7.noarch
    default: --> Processing Dependency: nginx-mod-http-perl = 1:1.16.1-1.el7 for package: 1:nginx-all-modules-1.16.1-1.el7.noarch
    default: --> Processing Dependency: nginx-mod-http-xslt-filter = 1:1.16.1-1.el7 for package: 1:nginx-all-modules-1.16.1-1.el7.noarch
    default: --> Processing Dependency: nginx-mod-mail = 1:1.16.1-1.el7 for package: 1:nginx-all-modules-1.16.1-1.el7.noarch
    default: --> Processing Dependency: nginx-mod-stream = 1:1.16.1-1.el7 for package: 1:nginx-all-modules-1.16.1-1.el7.noarch
    default: ---> Package nginx-filesystem.noarch 1:1.16.1-1.el7 will be installed
    default: --> Running transaction check
    default: ---> Package nginx-mod-http-image-filter.x86_64 1:1.16.1-1.el7 will be installed
    default: --> Processing Dependency: gd for package: 1:nginx-mod-http-image-filter-1.16.1-1.el7.x86_64
    default: --> Processing Dependency: libgd.so.2()(64bit) for package: 1:nginx-mod-http-image-filter-1.16.1-1.el7.x86_64
    default: ---> Package nginx-mod-http-perl.x86_64 1:1.16.1-1.el7 will be installed
    default: --> Processing Dependency: perl >= 5.006001 for package: 1:nginx-mod-http-perl-1.16.1-1.el7.x86_64
    default: --> Processing Dependency: perl(:MODULE_COMPAT_5.16.3) for package: 1:nginx-mod-http-perl-1.16.1-1.el7.x86_64
    default: --> Processing Dependency: perl(Exporter) for package: 1:nginx-mod-http-perl-1.16.1-1.el7.x86_64
    default: --> Processing Dependency: perl(XSLoader) for package: 1:nginx-mod-http-perl-1.16.1-1.el7.x86_64
    default: --> Processing Dependency: perl(constant) for package: 1:nginx-mod-http-perl-1.16.1-1.el7.x86_64
    default: --> Processing Dependency: perl(strict) for package: 1:nginx-mod-http-perl-1.16.1-1.el7.x86_64
    default: --> Processing Dependency: perl(warnings) for package: 1:nginx-mod-http-perl-1.16.1-1.el7.x86_64
    default: --> Processing Dependency: libperl.so()(64bit) for package: 1:nginx-mod-http-perl-1.16.1-1.el7.x86_64
    default: ---> Package nginx-mod-http-xslt-filter.x86_64 1:1.16.1-1.el7 will be installed
    default: ---> Package nginx-mod-mail.x86_64 1:1.16.1-1.el7 will be installed
    default: ---> Package nginx-mod-stream.x86_64 1:1.16.1-1.el7 will be installed
    default: --> Running transaction check
    default: ---> Package gd.x86_64 0:2.0.35-26.el7 will be installed
    default: --> Processing Dependency: libjpeg.so.62(LIBJPEG_6.2)(64bit) for package: gd-2.0.35-26.el7.x86_64
    default: --> Processing Dependency: libjpeg.so.62()(64bit) for package: gd-2.0.35-26.el7.x86_64
    default: --> Processing Dependency: libfontconfig.so.1()(64bit) for package: gd-2.0.35-26.el7.x86_64
    default: --> Processing Dependency: libXpm.so.4()(64bit) for package: gd-2.0.35-26.el7.x86_64
    default: --> Processing Dependency: libX11.so.6()(64bit) for package: gd-2.0.35-26.el7.x86_64
    default: ---> Package perl.x86_64 4:5.16.3-294.el7_6 will be installed
    default: --> Processing Dependency: perl(Socket) >= 1.3 for package: 4:perl-5.16.3-294.el7_6.x86_64
    default: --> Processing Dependency: perl(Scalar::Util) >= 1.10 for package: 4:perl-5.16.3-294.el7_6.x86_64
    default: --> Processing Dependency: perl-macros for package: 4:perl-5.16.3-294.el7_6.x86_64
    default: --> Processing Dependency: perl(threads::shared) for package: 4:perl-5.16.3-294.el7_6.x86_64
    default: --> Processing Dependency: perl(threads) for package: 4:perl-5.16.3-294.el7_6.x86_64
    default: --> Processing Dependency: perl(Time::Local) for package: 4:perl-5.16.3-294.el7_6.x86_64
    default: --> Processing Dependency: perl(Time::HiRes) for package: 4:perl-5.16.3-294.el7_6.x86_64
    default: --> Processing Dependency: perl(Storable) for package: 4:perl-5.16.3-294.el7_6.x86_64
    default: --> Processing Dependency: perl(Socket) for package: 4:perl-5.16.3-294.el7_6.x86_64
    default: --> Processing Dependency: perl(Scalar::Util) for package: 4:perl-5.16.3-294.el7_6.x86_64
    default: --> Processing Dependency: perl(Pod::Simple::XHTML) for package: 4:perl-5.16.3-294.el7_6.x86_64
    default: --> Processing Dependency: perl(Pod::Simple::Search) for package: 4:perl-5.16.3-294.el7_6.x86_64
    default: --> Processing Dependency: perl(Getopt::Long) for package: 4:perl-5.16.3-294.el7_6.x86_64
    default: --> Processing Dependency: perl(Filter::Util::Call) for package: 4:perl-5.16.3-294.el7_6.x86_64
    default: --> Processing Dependency: perl(File::Temp) for package: 4:perl-5.16.3-294.el7_6.x86_64
    default: --> Processing Dependency: perl(File::Spec::Unix) for package: 4:perl-5.16.3-294.el7_6.x86_64
    default: --> Processing Dependency: perl(File::Spec::Functions) for package: 4:perl-5.16.3-294.el7_6.x86_64
    default: --> Processing Dependency: perl(File::Spec) for package: 4:perl-5.16.3-294.el7_6.x86_64
    default: --> Processing Dependency: perl(File::Path) for package: 4:perl-5.16.3-294.el7_6.x86_64
    default: --> Processing Dependency: perl(Cwd) for package: 4:perl-5.16.3-294.el7_6.x86_64
    default: --> Processing Dependency: perl(Carp) for package: 4:perl-5.16.3-294.el7_6.x86_64
    default: ---> Package perl-Exporter.noarch 0:5.68-3.el7 will be installed
    default: ---> Package perl-constant.noarch 0:1.27-2.el7 will be installed
    default: ---> Package perl-libs.x86_64 4:5.16.3-294.el7_6 will be installed
    default: --> Running transaction check
    default: ---> Package fontconfig.x86_64 0:2.13.0-4.3.el7 will be installed
    default: --> Processing Dependency: fontpackages-filesystem for package: fontconfig-2.13.0-4.3.el7.x86_64
    default: --> Processing Dependency: dejavu-sans-fonts for package: fontconfig-2.13.0-4.3.el7.x86_64
    default: ---> Package libX11.x86_64 0:1.6.7-2.el7 will be installed
    default: --> Processing Dependency: libX11-common >= 1.6.7-2.el7 for package: libX11-1.6.7-2.el7.x86_64
    default: --> Processing Dependency: libxcb.so.1()(64bit) for package: libX11-1.6.7-2.el7.x86_64
    default: ---> Package libXpm.x86_64 0:3.5.12-1.el7 will be installed
    default: ---> Package libjpeg-turbo.x86_64 0:1.2.90-8.el7 will be installed
    default: ---> Package perl-Carp.noarch 0:1.26-244.el7 will be installed
    default: ---> Package perl-File-Path.noarch 0:2.09-2.el7 will be installed
    default: ---> Package perl-File-Temp.noarch 0:0.23.01-3.el7 will be installed
    default: ---> Package perl-Filter.x86_64 0:1.49-3.el7 will be installed
    default: ---> Package perl-Getopt-Long.noarch 0:2.40-3.el7 will be installed
    default: --> Processing Dependency: perl(Pod::Usage) >= 1.14 for package: perl-Getopt-Long-2.40-3.el7.noarch
    default: --> Processing Dependency: perl(Text::ParseWords) for package: perl-Getopt-Long-2.40-3.el7.noarch
    default: ---> Package perl-PathTools.x86_64 0:3.40-5.el7 will be installed
    default: ---> Package perl-Pod-Simple.noarch 1:3.28-4.el7 will be installed
    default: --> Processing Dependency: perl(Pod::Escapes) >= 1.04 for package: 1:perl-Pod-Simple-3.28-4.el7.noarch
    default: --> Processing Dependency: perl(Encode) for package: 1:perl-Pod-Simple-3.28-4.el7.noarch
    default: ---> Package perl-Scalar-List-Utils.x86_64 0:1.27-248.el7 will be installed
    default: ---> Package perl-Socket.x86_64 0:2.010-4.el7 will be installed
    default: ---> Package perl-Storable.x86_64 0:2.45-3.el7 will be installed
    default: ---> Package perl-Time-HiRes.x86_64 4:1.9725-3.el7 will be installed
    default: ---> Package perl-Time-Local.noarch 0:1.2300-2.el7 will be installed
    default: ---> Package perl-macros.x86_64 4:5.16.3-294.el7_6 will be installed
    default: ---> Package perl-threads.x86_64 0:1.87-4.el7 will be installed
    default: ---> Package perl-threads-shared.x86_64 0:1.43-6.el7 will be installed
    default: --> Running transaction check
    default: ---> Package dejavu-sans-fonts.noarch 0:2.33-6.el7 will be installed
    default: --> Processing Dependency: dejavu-fonts-common = 2.33-6.el7 for package: dejavu-sans-fonts-2.33-6.el7.noarch
    default: ---> Package fontpackages-filesystem.noarch 0:1.44-8.el7 will be installed
    default: ---> Package libX11-common.noarch 0:1.6.7-2.el7 will be installed
    default: ---> Package libxcb.x86_64 0:1.13-1.el7 will be installed
    default: --> Processing Dependency: libXau.so.6()(64bit) for package: libxcb-1.13-1.el7.x86_64
    default: ---> Package perl-Encode.x86_64 0:2.51-7.el7 will be installed
    default: ---> Package perl-Pod-Escapes.noarch 1:1.04-294.el7_6 will be installed
    default: ---> Package perl-Pod-Usage.noarch 0:1.63-3.el7 will be installed
    default: --> Processing Dependency: perl(Pod::Text) >= 3.15 for package: perl-Pod-Usage-1.63-3.el7.noarch
    default: --> Processing Dependency: perl-Pod-Perldoc for package: perl-Pod-Usage-1.63-3.el7.noarch
    default: ---> Package perl-Text-ParseWords.noarch 0:3.29-4.el7 will be installed
    default: --> Running transaction check
    default: ---> Package dejavu-fonts-common.noarch 0:2.33-6.el7 will be installed
    default: ---> Package libXau.x86_64 0:1.0.8-2.1.el7 will be installed
    default: ---> Package perl-Pod-Perldoc.noarch 0:3.20-4.el7 will be installed
    default: --> Processing Dependency: perl(parent) for package: perl-Pod-Perldoc-3.20-4.el7.noarch
    default: --> Processing Dependency: perl(HTTP::Tiny) for package: perl-Pod-Perldoc-3.20-4.el7.noarch
    default: ---> Package perl-podlators.noarch 0:2.5.1-3.el7 will be installed
    default: --> Running transaction check
    default: ---> Package perl-HTTP-Tiny.noarch 0:0.033-3.el7 will be installed
    default: ---> Package perl-parent.noarch 1:0.225-244.el7 will be installed
    default: --> Finished Dependency Resolution
    default:
    default: Dependencies Resolved
    default:
    default: ================================================================================
    default:  Package                        Arch      Version                 Repository
    default:                                                                            Size
    default: ================================================================================
    default: Installing:
    default:  nginx                          x86_64    1:1.16.1-1.el7          epel    562 k
    default: Installing for dependencies:
    default:  centos-indexhtml               noarch    7-9.el7.centos          base     92 k
    default:  centos-logos                   noarch    70.0.6-3.el7.centos     base     21 M
    default:  dejavu-fonts-common            noarch    2.33-6.el7              base     64 k
    default:  dejavu-sans-fonts              noarch    2.33-6.el7              base    1.4 M
    default:  fontconfig                     x86_64    2.13.0-4.3.el7          base    254 k
    default:  fontpackages-filesystem        noarch    1.44-8.el7              base    9.9 k
    default:  gd                             x86_64    2.0.35-26.el7           base    146 k
    default:  gperftools-libs                x86_64    2.6.1-1.el7             base    272 k
    default:  libX11                         x86_64    1.6.7-2.el7             base    607 k
    default:  libX11-common                  noarch    1.6.7-2.el7             base    164 k
    default:  libXau                         x86_64    1.0.8-2.1.el7           base     29 k
    default:  libXpm                         x86_64    3.5.12-1.el7            base     55 k
    default:  libjpeg-turbo                  x86_64    1.2.90-8.el7            base    135 k
    default:  libxcb                         x86_64    1.13-1.el7              base    214 k
    default:  nginx-all-modules              noarch    1:1.16.1-1.el7          epel     19 k
    default:  nginx-filesystem               noarch    1:1.16.1-1.el7          epel     21 k
    default:  nginx-mod-http-image-filter    x86_64    1:1.16.1-1.el7          epel     30 k
    default:  nginx-mod-http-perl            x86_64    1:1.16.1-1.el7          epel     39 k
    default:  nginx-mod-http-xslt-filter     x86_64    1:1.16.1-1.el7          epel     29 k
    default:  nginx-mod-mail                 x86_64    1:1.16.1-1.el7          epel     57 k
    default:  nginx-mod-stream               x86_64    1:1.16.1-1.el7          epel     84 k
    default:  perl                           x86_64    4:5.16.3-294.el7_6      base    8.0 M
    default:  perl-Carp                      noarch    1.26-244.el7            base     19 k
    default:  perl-Encode                    x86_64    2.51-7.el7              base    1.5 M
    default:  perl-Exporter                  noarch    5.68-3.el7              base     28 k
    default:  perl-File-Path                 noarch    2.09-2.el7              base     26 k
    default:  perl-File-Temp                 noarch    0.23.01-3.el7           base     56 k
    default:  perl-Filter                    x86_64    1.49-3.el7              base     76 k
    default:  perl-Getopt-Long               noarch    2.40-3.el7              base     56 k
    default:  perl-HTTP-Tiny                 noarch    0.033-3.el7             base     38 k
    default:  perl-PathTools                 x86_64    3.40-5.el7              base     82 k
    default:  perl-Pod-Escapes               noarch    1:1.04-294.el7_6        base     51 k
    default:  perl-Pod-Perldoc               noarch    3.20-4.el7              base     87 k
    default:  perl-Pod-Simple                noarch    1:3.28-4.el7            base    216 k
    default:  perl-Pod-Usage                 noarch    1.63-3.el7              base     27 k
    default:  perl-Scalar-List-Utils         x86_64    1.27-248.el7            base     36 k
    default:  perl-Socket                    x86_64    2.010-4.el7             base     49 k
    default:  perl-Storable                  x86_64    2.45-3.el7              base     77 k
    default:  perl-Text-ParseWords           noarch    3.29-4.el7              base     14 k
    default:  perl-Time-HiRes                x86_64    4:1.9725-3.el7          base     45 k
    default:  perl-Time-Local                noarch    1.2300-2.el7            base     24 k
    default:  perl-constant                  noarch    1.27-2.el7              base     19 k
    default:  perl-libs                      x86_64    4:5.16.3-294.el7_6      base    688 k
    default:  perl-macros                    x86_64    4:5.16.3-294.el7_6      base     44 k
    default:  perl-parent                    noarch    1:0.225-244.el7         base     12 k
    default:  perl-podlators                 noarch    2.5.1-3.el7             base    112 k
    default:  perl-threads                   x86_64    1.87-4.el7              base     49 k
    default:  perl-threads-shared            x86_64    1.43-6.el7              base     39 k
    default:
    default: Transaction Summary
    default: ================================================================================
    default: Install  1 Package (+48 Dependent packages)
    default: Total download size: 37 M
    default: Installed size: 72 M
    default: Downloading packages:
    default: warning: /var/cache/yum/x86_64/7/epel/packages/nginx-1.16.1-1.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
    default: Public key for nginx-1.16.1-1.el7.x86_64.rpm is not installed
    default: --------------------------------------------------------------------------------
    default: Total                                               13 MB/s |  37 MB  00:02
    default: Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
    default: Importing GPG key 0x352C64E5:
    default:  Userid     : "Fedora EPEL (7) <epel@fedoraproject.org>"
    default:  Fingerprint: 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5
    default:  Package    : epel-release-7-11.noarch (@extras)
    default:  From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
    default: Running transaction check
    default: Running transaction test
    default: Transaction test succeeded
    default: Running transaction
    default:   Installing : fontpackages-filesystem-1.44-8.el7.noarch                   1/49
    default:
    default:   Installing : dejavu-fonts-common-2.33-6.el7.noarch                       2/49
    default:
    default:   Installing : dejavu-sans-fonts-2.33-6.el7.noarch                         3/49
    default:
    default:   Installing : fontconfig-2.13.0-4.3.el7.x86_64                            4/49
    default:
    default:   Installing : 1:perl-parent-0.225-244.el7.noarch                          5/49
    default:
    default:   Installing : perl-HTTP-Tiny-0.033-3.el7.noarch                           6/49
    default:
    default:   Installing : perl-podlators-2.5.1-3.el7.noarch                           7/49
    default:
    default:   Installing : perl-Pod-Perldoc-3.20-4.el7.noarch                          8/49
    default:
    default:   Installing : 1:perl-Pod-Escapes-1.04-294.el7_6.noarch                    9/49
    default:
    default:   Installing : perl-Encode-2.51-7.el7.x86_64                              10/49
    default:
    default:   Installing : perl-Text-ParseWords-3.29-4.el7.noarch                     11/49
    default:
    default:   Installing : perl-Pod-Usage-1.63-3.el7.noarch                           12/49
    default:
    default:   Installing : 4:perl-libs-5.16.3-294.el7_6.x86_64                        13/49
    default:
    default:   Installing : 4:perl-macros-5.16.3-294.el7_6.x86_64                      14/49
    default:
    default:   Installing : 4:perl-Time-HiRes-1.9725-3.el7.x86_64                      15/49
    default:
    default:   Installing : perl-Exporter-5.68-3.el7.noarch                            16/49
    default:
    default:   Installing : perl-constant-1.27-2.el7.noarch                            17/49
    default:
    default:   Installing : perl-Time-Local-1.2300-2.el7.noarch                        18/49
    default:
    default:   Installing : perl-Socket-2.010-4.el7.x86_64                             19/49
    default:
    default:   Installing : perl-Carp-1.26-244.el7.noarch                              20/49
    default:
    default:   Installing : perl-Storable-2.45-3.el7.x86_64                            21/49
    default:
    default:   Installing : perl-PathTools-3.40-5.el7.x86_64                           22/49
    default:
    default:   Installing : perl-Scalar-List-Utils-1.27-248.el7.x86_64                 23/49
    default:
    default:   Installing : 1:perl-Pod-Simple-3.28-4.el7.noarch                        24/49
    default:
    default:   Installing : perl-File-Temp-0.23.01-3.el7.noarch                        25/49
    default:
    default:   Installing : perl-File-Path-2.09-2.el7.noarch                           26/49
    default:
    default:   Installing : perl-threads-shared-1.43-6.el7.x86_64                      27/49
    default:
    default:   Installing : perl-threads-1.87-4.el7.x86_64                             28/49
    default:
    default:   Installing : perl-Filter-1.49-3.el7.x86_64                              29/49
    default:
    default:   Installing : perl-Getopt-Long-2.40-3.el7.noarch                         30/49
    default:
    default:   Installing : 4:perl-5.16.3-294.el7_6.x86_64                             31/49
    default:
    default:   Installing : gperftools-libs-2.6.1-1.el7.x86_64                         32/49
    default:
    default:   Installing : libXau-1.0.8-2.1.el7.x86_64                                33/49
    default:
    default:   Installing : libxcb-1.13-1.el7.x86_64                                   34/49
    default:
    default:   Installing : centos-indexhtml-7-9.el7.centos.noarch                     35/49
    default:
    default:   Installing : libjpeg-turbo-1.2.90-8.el7.x86_64                          36/49
    default:
    default:   Installing : libX11-common-1.6.7-2.el7.noarch                           37/49
    default:
    default:   Installing : libX11-1.6.7-2.el7.x86_64                                  38/49
    default:
    default:   Installing : libXpm-3.5.12-1.el7.x86_64                                 39/49
    default:
    default:   Installing : gd-2.0.35-26.el7.x86_64                                    40/49
    default:
    default:   Installing : centos-logos-70.0.6-3.el7.centos.noarch                    41/49
    default:
    default:   Installing : 1:nginx-filesystem-1.16.1-1.el7.noarch                     42/49
    default:
    default:   Installing : 1:nginx-mod-mail-1.16.1-1.el7.x86_64                       43/49
    default:
    default:   Installing : 1:nginx-mod-stream-1.16.1-1.el7.x86_64                     44/49
    default:
    default:   Installing : 1:nginx-mod-http-xslt-filter-1.16.1-1.el7.x86_64           45/49
    default:
    default:   Installing : 1:nginx-mod-http-image-filter-1.16.1-1.el7.x86_64          46/49
    default:
    default:   Installing : 1:nginx-1.16.1-1.el7.x86_64                                47/49
    default:
    default:   Installing : 1:nginx-mod-http-perl-1.16.1-1.el7.x86_64                  48/49
    default:
    default:   Installing : 1:nginx-all-modules-1.16.1-1.el7.noarch                    49/49
    default:
    default:   Verifying  : perl-HTTP-Tiny-0.033-3.el7.noarch                           1/49
    default:
    default:   Verifying  : fontconfig-2.13.0-4.3.el7.x86_64                            2/49
    default:
    default:   Verifying  : 1:nginx-filesystem-1.16.1-1.el7.noarch                      3/49
    default:
    default:   Verifying  : perl-threads-shared-1.43-6.el7.x86_64                       4/49
    default:
    default:   Verifying  : 4:perl-Time-HiRes-1.9725-3.el7.x86_64                       5/49
    default:
    default:   Verifying  : 1:perl-Pod-Escapes-1.04-294.el7_6.noarch                    6/49
    default:
    default:   Verifying  : perl-Exporter-5.68-3.el7.noarch                             7/49
    default:
    default:   Verifying  : perl-constant-1.27-2.el7.noarch                             8/49
    default:
    default:   Verifying  : perl-PathTools-3.40-5.el7.x86_64                            9/49
    default:
    default:   Verifying  : 1:nginx-mod-mail-1.16.1-1.el7.x86_64                       10/49
    default:
    default:   Verifying  : 1:nginx-mod-http-perl-1.16.1-1.el7.x86_64                  11/49
    default:
    default:   Verifying  : dejavu-fonts-common-2.33-6.el7.noarch                      12/49
    default:
    default:   Verifying  : fontpackages-filesystem-1.44-8.el7.noarch                  13/49
    default:
    default:   Verifying  : centos-logos-70.0.6-3.el7.centos.noarch                    14/49
    default:
    default:   Verifying  : 1:perl-parent-0.225-244.el7.noarch                         15/49
    default:
    default:   Verifying  : perl-Pod-Usage-1.63-3.el7.noarch                           16/49
    default:
    default:   Verifying  : 4:perl-libs-5.16.3-294.el7_6.x86_64                        17/49
    default:
    default:   Verifying  : perl-File-Temp-0.23.01-3.el7.noarch                        18/49
    default:
    default:   Verifying  : 1:perl-Pod-Simple-3.28-4.el7.noarch                        19/49
    default:
    default:   Verifying  : libX11-1.6.7-2.el7.x86_64                                  20/49
    default:
    default:   Verifying  : libX11-common-1.6.7-2.el7.noarch                           21/49
    default:
    default:   Verifying  : libxcb-1.13-1.el7.x86_64                                   22/49
    default:
    default:   Verifying  : perl-Time-Local-1.2300-2.el7.noarch                        23/49
    default:
    default:   Verifying  : 4:perl-macros-5.16.3-294.el7_6.x86_64                      24/49
    default:
    default:   Verifying  : perl-Socket-2.010-4.el7.x86_64                             25/49
    default:
    default:   Verifying  : libXpm-3.5.12-1.el7.x86_64                                 26/49
    default:
    default:   Verifying  : 1:nginx-mod-stream-1.16.1-1.el7.x86_64                     27/49
    default:
    default:   Verifying  : perl-Carp-1.26-244.el7.noarch                              28/49
    default:
    default:   Verifying  : perl-Storable-2.45-3.el7.x86_64                            29/49
    default:
    default:   Verifying  : dejavu-sans-fonts-2.33-6.el7.noarch                        30/49
    default:
    default:   Verifying  : perl-Scalar-List-Utils-1.27-248.el7.x86_64                 31/49
    default:
    default:   Verifying  : 1:nginx-1.16.1-1.el7.x86_64                                32/49
    default:
    default:   Verifying  : libjpeg-turbo-1.2.90-8.el7.x86_64                          33/49
    default:
    default:   Verifying  : 1:nginx-all-modules-1.16.1-1.el7.noarch                    34/49
    default:
    default:   Verifying  : 1:nginx-mod-http-xslt-filter-1.16.1-1.el7.x86_64           35/49
    default:
    default:   Verifying  : centos-indexhtml-7-9.el7.centos.noarch                     36/49
    default:
    default:   Verifying  : 1:nginx-mod-http-image-filter-1.16.1-1.el7.x86_64          37/49
    default:
    default:   Verifying  : perl-Encode-2.51-7.el7.x86_64                              38/49
    default:
    default:   Verifying  : perl-Pod-Perldoc-3.20-4.el7.noarch                         39/49
    default:
    default:   Verifying  : perl-podlators-2.5.1-3.el7.noarch                          40/49
    default:
    default:   Verifying  : libXau-1.0.8-2.1.el7.x86_64                                41/49
    default:
    default:   Verifying  : perl-File-Path-2.09-2.el7.noarch                           42/49
    default:
    default:   Verifying  : perl-threads-1.87-4.el7.x86_64                             43/49
    default:
    default:   Verifying  : gperftools-libs-2.6.1-1.el7.x86_64                         44/49
    default:
    default:   Verifying  : perl-Filter-1.49-3.el7.x86_64                              45/49
    default:
    default:   Verifying  : perl-Getopt-Long-2.40-3.el7.noarch                         46/49
    default:
    default:   Verifying  : perl-Text-ParseWords-3.29-4.el7.noarch                     47/49
    default:
    default:   Verifying  : 4:perl-5.16.3-294.el7_6.x86_64                             48/49
    default:
    default:   Verifying  : gd-2.0.35-26.el7.x86_64                                    49/49
    default:
    default:
    default: Installed:
    default:   nginx.x86_64 1:1.16.1-1.el7
    default:
    default: Dependency Installed:
    default:   centos-indexhtml.noarch 0:7-9.el7.centos
    default:   centos-logos.noarch 0:70.0.6-3.el7.centos
    default:   dejavu-fonts-common.noarch 0:2.33-6.el7
    default:   dejavu-sans-fonts.noarch 0:2.33-6.el7
    default:   fontconfig.x86_64 0:2.13.0-4.3.el7
    default:   fontpackages-filesystem.noarch 0:1.44-8.el7
    default:   gd.x86_64 0:2.0.35-26.el7
    default:   gperftools-libs.x86_64 0:2.6.1-1.el7
    default:   libX11.x86_64 0:1.6.7-2.el7
    default:   libX11-common.noarch 0:1.6.7-2.el7
    default:   libXau.x86_64 0:1.0.8-2.1.el7
    default:   libXpm.x86_64 0:3.5.12-1.el7
    default:   libjpeg-turbo.x86_64 0:1.2.90-8.el7
    default:   libxcb.x86_64 0:1.13-1.el7
    default:   nginx-all-modules.noarch 1:1.16.1-1.el7
    default:   nginx-filesystem.noarch 1:1.16.1-1.el7
    default:   nginx-mod-http-image-filter.x86_64 1:1.16.1-1.el7
    default:   nginx-mod-http-perl.x86_64 1:1.16.1-1.el7
    default:   nginx-mod-http-xslt-filter.x86_64 1:1.16.1-1.el7
    default:   nginx-mod-mail.x86_64 1:1.16.1-1.el7
    default:   nginx-mod-stream.x86_64 1:1.16.1-1.el7
    default:   perl.x86_64 4:5.16.3-294.el7_6
    default:   perl-Carp.noarch 0:1.26-244.el7
    default:   perl-Encode.x86_64 0:2.51-7.el7
    default:   perl-Exporter.noarch 0:5.68-3.el7
    default:   perl-File-Path.noarch 0:2.09-2.el7
    default:   perl-File-Temp.noarch 0:0.23.01-3.el7
    default:   perl-Filter.x86_64 0:1.49-3.el7
    default:   perl-Getopt-Long.noarch 0:2.40-3.el7
    default:   perl-HTTP-Tiny.noarch 0:0.033-3.el7
    default:   perl-PathTools.x86_64 0:3.40-5.el7
    default:   perl-Pod-Escapes.noarch 1:1.04-294.el7_6
    default:   perl-Pod-Perldoc.noarch 0:3.20-4.el7
    default:   perl-Pod-Simple.noarch 1:3.28-4.el7
    default:   perl-Pod-Usage.noarch 0:1.63-3.el7
    default:   perl-Scalar-List-Utils.x86_64 0:1.27-248.el7
    default:   perl-Socket.x86_64 0:2.010-4.el7
    default:   perl-Storable.x86_64 0:2.45-3.el7
    default:   perl-Text-ParseWords.noarch 0:3.29-4.el7
    default:   perl-Time-HiRes.x86_64 4:1.9725-3.el7
    default:   perl-Time-Local.noarch 0:1.2300-2.el7
    default:   perl-constant.noarch 0:1.27-2.el7
    default:   perl-libs.x86_64 4:5.16.3-294.el7_6
    default:   perl-macros.x86_64 4:5.16.3-294.el7_6
    default:   perl-parent.noarch 1:0.225-244.el7
    default:   perl-podlators.noarch 0:2.5.1-3.el7
    default:   perl-threads.x86_64 0:1.87-4.el7
    default:   perl-threads-shared.x86_64 0:1.43-6.el7
    default: Complete!
    default: Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
    default: success
    default: success
PS C:\vagrant\my_centos>

エクスターナルスクリプト

Vagrantfile とは別のファイルにシェルを記述し、そのファイルを実行します。

プロビジョニングで実行するシェルスクリプトです。

PS C:\vagrant\my_centos> cat .\provision\nginx.sh
yum -y install epel-release
yum -y install nginx
systemctl start nginx
systemctl enable nginx
systemctl start firewalld
firewall-cmd --add-service=http --permanent
firewall-cmd --reload
PS C:\vagrant\my_centos>

Vagrantfile です。path:で実行するシェルスクリプトファイルを指定します。

Vagrant.configure("2") do |config|
  config.vm.box = "centos/7"
  config.vm.network "public_network", mac: "080027000001"
  config.vm.hostname = "web-sv"
  config.vm.provider "virtualbox" do |vb|
    vb.gui = true
    vb.name = "nginx"
    vb.memory = "4096"
    vb.cpus = 2
    vb.customize [
      "modifyvm", :id,
      "--ioapic", "on",
      "--graphicscontroller", "vmsvga"
    ]
  end
  config.vm.provision "shell", path: "./provision/nginx.sh"
end

実行結果です。

PS C:\vagrant\my_centos> vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'centos/7'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'centos/7' version '1905.1' is up to date...
==> default: Setting the name of the VM: nginx
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: bridged
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default:
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default:
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: No guest additions were detected on the base box for this VM! Guest
    default: additions are required for forwarded ports, shared folders, host only
    default: networking, and more. If SSH fails on this machine, please install
    default: the guest additions and repackage the box to continue.
    default:
    default: This is not an error message; everything may continue to work properly,
    default: in which case you may ignore this message.
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Rsyncing folder: /cygdrive/c/vagrant/my_centos/ => /vagrant
==> default: Running provisioner: shell...
    default: Running: C:/Users/user/AppData/Local/Temp/vagrant-shell20200208-16956-1flu3hj.sh
    default: Loaded plugins: fastestmirror
    default: Determining fastest mirrors
    default:  * base: ftp.iij.ad.jp
    default:  * extras: ftp.iij.ad.jp
    default:  * updates: ftp.iij.ad.jp
    default: Resolving Dependencies
    default: --> Running transaction check
    default: ---> Package epel-release.noarch 0:7-11 will be installed
    default: --> Finished Dependency Resolution
    default:
    default: Dependencies Resolved
    default:
    default: ================================================================================
    default:  Package                Arch             Version         Repository        Size
    default: ================================================================================
    default: Installing:
    default:  epel-release           noarch           7-11            extras            15 k
    default:
    default: Transaction Summary
    default: ================================================================================
    default: Install  1 Package
    default:
    default: Total download size: 15 k
    default: Installed size: 24 k
    default: Downloading packages:
    default: Public key for epel-release-7-11.noarch.rpm is not installed
    default: warning: /var/cache/yum/x86_64/7/extras/packages/epel-release-7-11.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
    default: Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
    default: Importing GPG key 0xF4A80EB5:
    default:  Userid     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
    default:  Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
    default:  Package    : centos-release-7-6.1810.2.el7.centos.x86_64 (@anaconda)
    default:  From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
    default: Running transaction check
    default: Running transaction test
    default: Transaction test succeeded
    default: Running transaction
    default:   Installing : epel-release-7-11.noarch                                     1/1
    default:
    default:   Verifying  : epel-release-7-11.noarch                                     1/1
    default:
    default:
    default: Installed:
    default:   epel-release.noarch 0:7-11
    default: Complete!
    default: Loaded plugins: fastestmirror
    default: Loading mirror speeds from cached hostfile
    default:  * base: ftp.iij.ad.jp
    default:  * epel: ftp.iij.ad.jp
    default:  * extras: ftp.iij.ad.jp
    default:  * updates: ftp.iij.ad.jp
    default: Resolving Dependencies
    default: --> Running transaction check
    default: ---> Package nginx.x86_64 1:1.16.1-1.el7 will be installed
    default: --> Processing Dependency: nginx-all-modules = 1:1.16.1-1.el7 for package: 1:nginx-1.16.1-1.el7.x86_64
    default: --> Processing Dependency: nginx-filesystem = 1:1.16.1-1.el7 for package: 1:nginx-1.16.1-1.el7.x86_64
    default: --> Processing Dependency: nginx-filesystem for package: 1:nginx-1.16.1-1.el7.x86_64
    default: --> Processing Dependency: redhat-indexhtml for package: 1:nginx-1.16.1-1.el7.x86_64
    default: --> Processing Dependency: system-logos for package: 1:nginx-1.16.1-1.el7.x86_64
    default: --> Processing Dependency: libprofiler.so.0()(64bit) for package: 1:nginx-1.16.1-1.el7.x86_64
    default: --> Running transaction check
    default: ---> Package centos-indexhtml.noarch 0:7-9.el7.centos will be installed
    default: ---> Package centos-logos.noarch 0:70.0.6-3.el7.centos will be installed
    default: ---> Package gperftools-libs.x86_64 0:2.6.1-1.el7 will be installed
    default: ---> Package nginx-all-modules.noarch 1:1.16.1-1.el7 will be installed
    default: --> Processing Dependency: nginx-mod-http-image-filter = 1:1.16.1-1.el7 for package: 1:nginx-all-modules-1.16.1-1.el7.noarch
    default: --> Processing Dependency: nginx-mod-http-perl = 1:1.16.1-1.el7 for package: 1:nginx-all-modules-1.16.1-1.el7.noarch
    default: --> Processing Dependency: nginx-mod-http-xslt-filter = 1:1.16.1-1.el7 for package: 1:nginx-all-modules-1.16.1-1.el7.noarch
    default: --> Processing Dependency: nginx-mod-mail = 1:1.16.1-1.el7 for package: 1:nginx-all-modules-1.16.1-1.el7.noarch
    default: --> Processing Dependency: nginx-mod-stream = 1:1.16.1-1.el7 for package: 1:nginx-all-modules-1.16.1-1.el7.noarch
    default: ---> Package nginx-filesystem.noarch 1:1.16.1-1.el7 will be installed
    default: --> Running transaction check
    default: ---> Package nginx-mod-http-image-filter.x86_64 1:1.16.1-1.el7 will be installed
    default: --> Processing Dependency: gd for package: 1:nginx-mod-http-image-filter-1.16.1-1.el7.x86_64
    default: --> Processing Dependency: libgd.so.2()(64bit) for package: 1:nginx-mod-http-image-filter-1.16.1-1.el7.x86_64
    default: ---> Package nginx-mod-http-perl.x86_64 1:1.16.1-1.el7 will be installed
    default: --> Processing Dependency: perl >= 5.006001 for package: 1:nginx-mod-http-perl-1.16.1-1.el7.x86_64
    default: --> Processing Dependency: perl(:MODULE_COMPAT_5.16.3) for package: 1:nginx-mod-http-perl-1.16.1-1.el7.x86_64
    default: --> Processing Dependency: perl(Exporter) for package: 1:nginx-mod-http-perl-1.16.1-1.el7.x86_64
    default: --> Processing Dependency: perl(XSLoader) for package: 1:nginx-mod-http-perl-1.16.1-1.el7.x86_64
    default: --> Processing Dependency: perl(constant) for package: 1:nginx-mod-http-perl-1.16.1-1.el7.x86_64
    default: --> Processing Dependency: perl(strict) for package: 1:nginx-mod-http-perl-1.16.1-1.el7.x86_64
    default: --> Processing Dependency: perl(warnings) for package: 1:nginx-mod-http-perl-1.16.1-1.el7.x86_64
    default: --> Processing Dependency: libperl.so()(64bit) for package: 1:nginx-mod-http-perl-1.16.1-1.el7.x86_64
    default: ---> Package nginx-mod-http-xslt-filter.x86_64 1:1.16.1-1.el7 will be installed
    default: ---> Package nginx-mod-mail.x86_64 1:1.16.1-1.el7 will be installed
    default: ---> Package nginx-mod-stream.x86_64 1:1.16.1-1.el7 will be installed
    default: --> Running transaction check
    default: ---> Package gd.x86_64 0:2.0.35-26.el7 will be installed
    default: --> Processing Dependency: libjpeg.so.62(LIBJPEG_6.2)(64bit) for package: gd-2.0.35-26.el7.x86_64
    default: --> Processing Dependency: libjpeg.so.62()(64bit) for package: gd-2.0.35-26.el7.x86_64
    default: --> Processing Dependency: libfontconfig.so.1()(64bit) for package: gd-2.0.35-26.el7.x86_64
    default: --> Processing Dependency: libXpm.so.4()(64bit) for package: gd-2.0.35-26.el7.x86_64
    default: --> Processing Dependency: libX11.so.6()(64bit) for package: gd-2.0.35-26.el7.x86_64
    default: ---> Package perl.x86_64 4:5.16.3-294.el7_6 will be installed
    default: --> Processing Dependency: perl(Socket) >= 1.3 for package: 4:perl-5.16.3-294.el7_6.x86_64
    default: --> Processing Dependency: perl(Scalar::Util) >= 1.10 for package: 4:perl-5.16.3-294.el7_6.x86_64
    default: --> Processing Dependency: perl-macros for package: 4:perl-5.16.3-294.el7_6.x86_64
    default: --> Processing Dependency: perl(threads::shared) for package: 4:perl-5.16.3-294.el7_6.x86_64
    default: --> Processing Dependency: perl(threads) for package: 4:perl-5.16.3-294.el7_6.x86_64
    default: --> Processing Dependency: perl(Time::Local) for package: 4:perl-5.16.3-294.el7_6.x86_64
    default: --> Processing Dependency: perl(Time::HiRes) for package: 4:perl-5.16.3-294.el7_6.x86_64
    default: --> Processing Dependency: perl(Storable) for package: 4:perl-5.16.3-294.el7_6.x86_64
    default: --> Processing Dependency: perl(Socket) for package: 4:perl-5.16.3-294.el7_6.x86_64
    default: --> Processing Dependency: perl(Scalar::Util) for package: 4:perl-5.16.3-294.el7_6.x86_64
    default: --> Processing Dependency: perl(Pod::Simple::XHTML) for package: 4:perl-5.16.3-294.el7_6.x86_64
    default: --> Processing Dependency: perl(Pod::Simple::Search) for package: 4:perl-5.16.3-294.el7_6.x86_64
    default: --> Processing Dependency: perl(Getopt::Long) for package: 4:perl-5.16.3-294.el7_6.x86_64
    default: --> Processing Dependency: perl(Filter::Util::Call) for package: 4:perl-5.16.3-294.el7_6.x86_64
    default: --> Processing Dependency: perl(File::Temp) for package: 4:perl-5.16.3-294.el7_6.x86_64
    default: --> Processing Dependency: perl(File::Spec::Unix) for package: 4:perl-5.16.3-294.el7_6.x86_64
    default: --> Processing Dependency: perl(File::Spec::Functions) for package: 4:perl-5.16.3-294.el7_6.x86_64
    default: --> Processing Dependency: perl(File::Spec) for package: 4:perl-5.16.3-294.el7_6.x86_64
    default: --> Processing Dependency: perl(File::Path) for package: 4:perl-5.16.3-294.el7_6.x86_64
    default: --> Processing Dependency: perl(Cwd) for package: 4:perl-5.16.3-294.el7_6.x86_64
    default: --> Processing Dependency: perl(Carp) for package: 4:perl-5.16.3-294.el7_6.x86_64
    default: ---> Package perl-Exporter.noarch 0:5.68-3.el7 will be installed
    default: ---> Package perl-constant.noarch 0:1.27-2.el7 will be installed
    default: ---> Package perl-libs.x86_64 4:5.16.3-294.el7_6 will be installed
    default: --> Running transaction check
    default: ---> Package fontconfig.x86_64 0:2.13.0-4.3.el7 will be installed
    default: --> Processing Dependency: fontpackages-filesystem for package: fontconfig-2.13.0-4.3.el7.x86_64
    default: --> Processing Dependency: dejavu-sans-fonts for package: fontconfig-2.13.0-4.3.el7.x86_64
    default: ---> Package libX11.x86_64 0:1.6.7-2.el7 will be installed
    default: --> Processing Dependency: libX11-common >= 1.6.7-2.el7 for package: libX11-1.6.7-2.el7.x86_64
    default: --> Processing Dependency: libxcb.so.1()(64bit) for package: libX11-1.6.7-2.el7.x86_64
    default: ---> Package libXpm.x86_64 0:3.5.12-1.el7 will be installed
    default: ---> Package libjpeg-turbo.x86_64 0:1.2.90-8.el7 will be installed
    default: ---> Package perl-Carp.noarch 0:1.26-244.el7 will be installed
    default: ---> Package perl-File-Path.noarch 0:2.09-2.el7 will be installed
    default: ---> Package perl-File-Temp.noarch 0:0.23.01-3.el7 will be installed
    default: ---> Package perl-Filter.x86_64 0:1.49-3.el7 will be installed
    default: ---> Package perl-Getopt-Long.noarch 0:2.40-3.el7 will be installed
    default: --> Processing Dependency: perl(Pod::Usage) >= 1.14 for package: perl-Getopt-Long-2.40-3.el7.noarch
    default: --> Processing Dependency: perl(Text::ParseWords) for package: perl-Getopt-Long-2.40-3.el7.noarch
    default: ---> Package perl-PathTools.x86_64 0:3.40-5.el7 will be installed
    default: ---> Package perl-Pod-Simple.noarch 1:3.28-4.el7 will be installed
    default: --> Processing Dependency: perl(Pod::Escapes) >= 1.04 for package: 1:perl-Pod-Simple-3.28-4.el7.noarch
    default: --> Processing Dependency: perl(Encode) for package: 1:perl-Pod-Simple-3.28-4.el7.noarch
    default: ---> Package perl-Scalar-List-Utils.x86_64 0:1.27-248.el7 will be installed
    default: ---> Package perl-Socket.x86_64 0:2.010-4.el7 will be installed
    default: ---> Package perl-Storable.x86_64 0:2.45-3.el7 will be installed
    default: ---> Package perl-Time-HiRes.x86_64 4:1.9725-3.el7 will be installed
    default: ---> Package perl-Time-Local.noarch 0:1.2300-2.el7 will be installed
    default: ---> Package perl-macros.x86_64 4:5.16.3-294.el7_6 will be installed
    default: ---> Package perl-threads.x86_64 0:1.87-4.el7 will be installed
    default: ---> Package perl-threads-shared.x86_64 0:1.43-6.el7 will be installed
    default: --> Running transaction check
    default: ---> Package dejavu-sans-fonts.noarch 0:2.33-6.el7 will be installed
    default: --> Processing Dependency: dejavu-fonts-common = 2.33-6.el7 for package: dejavu-sans-fonts-2.33-6.el7.noarch
    default: ---> Package fontpackages-filesystem.noarch 0:1.44-8.el7 will be installed
    default: ---> Package libX11-common.noarch 0:1.6.7-2.el7 will be installed
    default: ---> Package libxcb.x86_64 0:1.13-1.el7 will be installed
    default: --> Processing Dependency: libXau.so.6()(64bit) for package: libxcb-1.13-1.el7.x86_64
    default: ---> Package perl-Encode.x86_64 0:2.51-7.el7 will be installed
    default: ---> Package perl-Pod-Escapes.noarch 1:1.04-294.el7_6 will be installed
    default: ---> Package perl-Pod-Usage.noarch 0:1.63-3.el7 will be installed
    default: --> Processing Dependency: perl(Pod::Text) >= 3.15 for package: perl-Pod-Usage-1.63-3.el7.noarch
    default: --> Processing Dependency: perl-Pod-Perldoc for package: perl-Pod-Usage-1.63-3.el7.noarch
    default: ---> Package perl-Text-ParseWords.noarch 0:3.29-4.el7 will be installed
    default: --> Running transaction check
    default: ---> Package dejavu-fonts-common.noarch 0:2.33-6.el7 will be installed
    default: ---> Package libXau.x86_64 0:1.0.8-2.1.el7 will be installed
    default: ---> Package perl-Pod-Perldoc.noarch 0:3.20-4.el7 will be installed
    default: --> Processing Dependency: perl(parent) for package: perl-Pod-Perldoc-3.20-4.el7.noarch
    default: --> Processing Dependency: perl(HTTP::Tiny) for package: perl-Pod-Perldoc-3.20-4.el7.noarch
    default: ---> Package perl-podlators.noarch 0:2.5.1-3.el7 will be installed
    default: --> Running transaction check
    default: ---> Package perl-HTTP-Tiny.noarch 0:0.033-3.el7 will be installed
    default: ---> Package perl-parent.noarch 1:0.225-244.el7 will be installed
    default: --> Finished Dependency Resolution
    default:
    default: Dependencies Resolved
    default:
    default: ================================================================================
    default:  Package                        Arch      Version                 Repository
    default:                                                                            Size
    default: ================================================================================
    default: Installing:
    default:  nginx                          x86_64    1:1.16.1-1.el7          epel    562 k
    default: Installing for dependencies:
    default:  centos-indexhtml               noarch    7-9.el7.centos          base     92 k
    default:  centos-logos                   noarch    70.0.6-3.el7.centos     base     21 M
    default:  dejavu-fonts-common            noarch    2.33-6.el7              base     64 k
    default:  dejavu-sans-fonts              noarch    2.33-6.el7              base    1.4 M
    default:  fontconfig                     x86_64    2.13.0-4.3.el7          base    254 k
    default:  fontpackages-filesystem        noarch    1.44-8.el7              base    9.9 k
    default:  gd                             x86_64    2.0.35-26.el7           base    146 k
    default:  gperftools-libs                x86_64    2.6.1-1.el7             base    272 k
    default:  libX11                         x86_64    1.6.7-2.el7             base    607 k
    default:  libX11-common                  noarch    1.6.7-2.el7             base    164 k
    default:  libXau                         x86_64    1.0.8-2.1.el7           base     29 k
    default:  libXpm                         x86_64    3.5.12-1.el7            base     55 k
    default:  libjpeg-turbo                  x86_64    1.2.90-8.el7            base    135 k
    default:  libxcb                         x86_64    1.13-1.el7              base    214 k
    default:  nginx-all-modules              noarch    1:1.16.1-1.el7          epel     19 k
    default:  nginx-filesystem               noarch    1:1.16.1-1.el7          epel     21 k
    default:  nginx-mod-http-image-filter    x86_64    1:1.16.1-1.el7          epel     30 k
    default:  nginx-mod-http-perl            x86_64    1:1.16.1-1.el7          epel     39 k
    default:  nginx-mod-http-xslt-filter     x86_64    1:1.16.1-1.el7          epel     29 k
    default:  nginx-mod-mail                 x86_64    1:1.16.1-1.el7          epel     57 k
    default:  nginx-mod-stream               x86_64    1:1.16.1-1.el7          epel     84 k
    default:  perl                           x86_64    4:5.16.3-294.el7_6      base    8.0 M
    default:  perl-Carp                      noarch    1.26-244.el7            base     19 k
    default:  perl-Encode                    x86_64    2.51-7.el7              base    1.5 M
    default:  perl-Exporter                  noarch    5.68-3.el7              base     28 k
    default:  perl-File-Path                 noarch    2.09-2.el7              base     26 k
    default:  perl-File-Temp                 noarch    0.23.01-3.el7           base     56 k
    default:  perl-Filter                    x86_64    1.49-3.el7              base     76 k
    default:  perl-Getopt-Long               noarch    2.40-3.el7              base     56 k
    default:  perl-HTTP-Tiny                 noarch    0.033-3.el7             base     38 k
    default:  perl-PathTools                 x86_64    3.40-5.el7              base     82 k
    default:  perl-Pod-Escapes               noarch    1:1.04-294.el7_6        base     51 k
    default:  perl-Pod-Perldoc               noarch    3.20-4.el7              base     87 k
    default:  perl-Pod-Simple                noarch    1:3.28-4.el7            base    216 k
    default:  perl-Pod-Usage                 noarch    1.63-3.el7              base     27 k
    default:  perl-Scalar-List-Utils         x86_64    1.27-248.el7            base     36 k
    default:  perl-Socket                    x86_64    2.010-4.el7             base     49 k
    default:  perl-Storable                  x86_64    2.45-3.el7              base     77 k
    default:  perl-Text-ParseWords           noarch    3.29-4.el7              base     14 k
    default:  perl-Time-HiRes                x86_64    4:1.9725-3.el7          base     45 k
    default:  perl-Time-Local                noarch    1.2300-2.el7            base     24 k
    default:  perl-constant                  noarch    1.27-2.el7              base     19 k
    default:  perl-libs                      x86_64    4:5.16.3-294.el7_6      base    688 k
    default:  perl-macros                    x86_64    4:5.16.3-294.el7_6      base     44 k
    default:  perl-parent                    noarch    1:0.225-244.el7         base     12 k
    default:  perl-podlators                 noarch    2.5.1-3.el7
    default:            base    112 k
    default:  perl-threads                   x86_64    1.87-4.el7              base     49 k
    default:  perl-threads-shared            x86_64    1.43-6.el7              base     39 k
    default:
    default: Transaction Summary
    default: ================================================================================
    default: Install  1 Package (+48 Dependent packages)
    default: Total download size: 37 M
    default: Installed size: 72 M
    default: Downloading packages:
    default: Public key for nginx-all-modules-1.16.1-1.el7.noarch.rpm is not installed
    default: warning: /var/cache/yum/x86_64/7/epel/packages/nginx-all-modules-1.16.1-1.el7.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
    default: --------------------------------------------------------------------------------
    default: Total                                              9.7 MB/s |  37 MB  00:03
    default: Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
    default: Importing GPG key 0x352C64E5:
    default:  Userid     : "Fedora EPEL (7) <epel@fedoraproject.org>"
    default:  Fingerprint: 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5
    default:  Package    : epel-release-7-11.noarch (@extras)
    default:  From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
    default: Running transaction check
    default: Running transaction test
    default: Transaction test succeeded
    default: Running transaction
    default:   Installing : fontpackages-filesystem-1.44-8.el7.noarch                   1/49
    default:
    default:   Installing : dejavu-fonts-common-2.33-6.el7.noarch                       2/49
    default:
    default:   Installing : dejavu-sans-fonts-2.33-6.el7.noarch                         3/49
    default:
    default:   Installing : fontconfig-2.13.0-4.3.el7.x86_64                            4/49
    default:
    default:   Installing : 1:perl-parent-0.225-244.el7.noarch                          5/49
    default:
    default:   Installing : perl-HTTP-Tiny-0.033-3.el7.noarch                           6/49
    default:
    default:   Installing : perl-podlators-2.5.1-3.el7.noarch                           7/49
    default:
    default:   Installing : perl-Pod-Perldoc-3.20-4.el7.noarch                          8/49
    default:
    default:   Installing : 1:perl-Pod-Escapes-1.04-294.el7_6.noarch                    9/49
    default:
    default:   Installing : perl-Encode-2.51-7.el7.x86_64                              10/49
    default:
    default:   Installing : perl-Text-ParseWords-3.29-4.el7.noarch                     11/49
    default:
    default:   Installing : perl-Pod-Usage-1.63-3.el7.noarch                           12/49
    default:
    default:   Installing : 4:perl-libs-5.16.3-294.el7_6.x86_64                        13/49
    default:
    default:   Installing : 4:perl-macros-5.16.3-294.el7_6.x86_64                      14/49
    default:
    default:   Installing : 4:perl-Time-HiRes-1.9725-3.el7.x86_64                      15/49
    default:
    default:   Installing : perl-Exporter-5.68-3.el7.noarch                            16/49
    default:
    default:   Installing : perl-constant-1.27-2.el7.noarch                            17/49
    default:
    default:   Installing : perl-Time-Local-1.2300-2.el7.noarch                        18/49
    default:
    default:   Installing : perl-Socket-2.010-4.el7.x86_64                             19/49
    default:
    default:   Installing : perl-Carp-1.26-244.el7.noarch                              20/49
    default:
    default:   Installing : perl-Storable-2.45-3.el7.x86_64                            21/49
    default:
    default:   Installing : perl-PathTools-3.40-5.el7.x86_64                           22/49
    default:
    default:   Installing : perl-Scalar-List-Utils-1.27-248.el7.x86_64                 23/49
    default:
    default:   Installing : 1:perl-Pod-Simple-3.28-4.el7.noarch                        24/49
    default:
    default:   Installing : perl-File-Temp-0.23.01-3.el7.noarch                        25/49
    default:
    default:   Installing : perl-File-Path-2.09-2.el7.noarch                           26/49
    default:
    default:   Installing : perl-threads-shared-1.43-6.el7.x86_64                      27/49
    default:
    default:   Installing : perl-threads-1.87-4.el7.x86_64                             28/49
    default:
    default:   Installing : perl-Filter-1.49-3.el7.x86_64                              29/49
    default:
    default:   Installing : perl-Getopt-Long-2.40-3.el7.noarch                         30/49
    default:
    default:   Installing : 4:perl-5.16.3-294.el7_6.x86_64                             31/49
    default:
    default:   Installing : gperftools-libs-2.6.1-1.el7.x86_64                         32/49
    default:
    default:   Installing : libXau-1.0.8-2.1.el7.x86_64                                33/49
    default:
    default:   Installing : libxcb-1.13-1.el7.x86_64                                   34/49
    default:
    default:   Installing : centos-indexhtml-7-9.el7.centos.noarch                     35/49
    default:
    default:   Installing : libjpeg-turbo-1.2.90-8.el7.x86_64                          36/49
    default:
    default:   Installing : libX11-common-1.6.7-2.el7.noarch                           37/49
    default:
    default:   Installing : libX11-1.6.7-2.el7.x86_64                                  38/49
    default:
    default:   Installing : libXpm-3.5.12-1.el7.x86_64                                 39/49
    default:
    default:   Installing : gd-2.0.35-26.el7.x86_64                                    40/49
    default:
    default:   Installing : centos-logos-70.0.6-3.el7.centos.noarch                    41/49
    default:
    default:   Installing : 1:nginx-filesystem-1.16.1-1.el7.noarch                     42/49
    default:
    default:   Installing : 1:nginx-mod-mail-1.16.1-1.el7.x86_64                       43/49
    default:
    default:   Installing : 1:nginx-mod-stream-1.16.1-1.el7.x86_64                     44/49
    default:
    default:   Installing : 1:nginx-mod-http-xslt-filter-1.16.1-1.el7.x86_64           45/49
    default:
    default:   Installing : 1:nginx-mod-http-image-filter-1.16.1-1.el7.x86_64          46/49
    default:
    default:   Installing : 1:nginx-1.16.1-1.el7.x86_64                                47/49
    default:
    default:   Installing : 1:nginx-mod-http-perl-1.16.1-1.el7.x86_64                  48/49
    default:
    default:   Installing : 1:nginx-all-modules-1.16.1-1.el7.noarch                    49/49
    default:
    default:   Verifying  : perl-HTTP-Tiny-0.033-3.el7.noarch                           1/49
    default:
    default:   Verifying  : fontconfig-2.13.0-4.3.el7.x86_64                            2/49
    default:
    default:   Verifying  : 1:nginx-filesystem-1.16.1-1.el7.noarch                      3/49
    default:
    default:   Verifying  : perl-threads-shared-1.43-6.el7.x86_64                       4/49
    default:
    default:   Verifying  : 4:perl-Time-HiRes-1.9725-3.el7.x86_64                       5/49
    default:
    default:   Verifying  : 1:perl-Pod-Escapes-1.04-294.el7_6.noarch                    6/49
    default:
    default:   Verifying  : perl-Exporter-5.68-3.el7.noarch                             7/49
    default:
    default:   Verifying  : perl-constant-1.27-2.el7.noarch                             8/49
    default:
    default:   Verifying  : perl-PathTools-3.40-5.el7.x86_64                            9/49
    default:
    default:   Verifying  : 1:nginx-mod-mail-1.16.1-1.el7.x86_64                       10/49
    default:
    default:   Verifying  : 1:nginx-mod-http-perl-1.16.1-1.el7.x86_64                  11/49
    default:
    default:   Verifying  : dejavu-fonts-common-2.33-6.el7.noarch                      12/49
    default:
    default:   Verifying  : fontpackages-filesystem-1.44-8.el7.noarch                  13/49
    default:
    default:   Verifying  : centos-logos-70.0.6-3.el7.centos.noarch                    14/49
    default:
    default:   Verifying  : 1:perl-parent-0.225-244.el7.noarch                         15/49
    default:
    default:   Verifying  : perl-Pod-Usage-1.63-3.el7.noarch                           16/49
    default:
    default:   Verifying  : 4:perl-libs-5.16.3-294.el7_6.x86_64                        17/49
    default:
    default:   Verifying  : perl-File-Temp-0.23.01-3.el7.noarch                        18/49
    default:
    default:   Verifying  : 1:perl-Pod-Simple-3.28-4.el7.noarch                        19/49
    default:
    default:   Verifying  : libX11-1.6.7-2.el7.x86_64                                  20/49
    default:
    default:   Verifying  : libX11-common-1.6.7-2.el7.noarch                           21/49
    default:
    default:   Verifying  : libxcb-1.13-1.el7.x86_64                                   22/49
    default:
    default:   Verifying  : perl-Time-Local-1.2300-2.el7.noarch                        23/49
    default:
    default:   Verifying  : 4:perl-macros-5.16.3-294.el7_6.x86_64                      24/49
    default:
    default:   Verifying  : perl-Socket-2.010-4.el7.x86_64                             25/49
    default:
    default:   Verifying  : libXpm-3.5.12-1.el7.x86_64                                 26/49
    default:
    default:   Verifying  : 1:nginx-mod-stream-1.16.1-1.el7.x86_64                     27/49
    default:
    default:   Verifying  : perl-Carp-1.26-244.el7.noarch                              28/49
    default:
    default:   Verifying  : perl-Storable-2.45-3.el7.x86_64                            29/49
    default:
    default:   Verifying  : dejavu-sans-fonts-2.33-6.el7.noarch                        30/49
    default:
    default:   Verifying  : perl-Scalar-List-Utils-1.27-248.el7.x86_64                 31/49
    default:
    default:   Verifying  : 1:nginx-1.16.1-1.el7.x86_64                                32/49
    default:
    default:   Verifying  : libjpeg-turbo-1.2.90-8.el7.x86_64                          33/49
    default:
    default:   Verifying  : 1:nginx-all-modules-1.16.1-1.el7.noarch                    34/49
    default:
    default:   Verifying  : 1:nginx-mod-http-xslt-filter-1.16.1-1.el7.x86_64           35/49
    default:
    default:   Verifying  : centos-indexhtml-7-9.el7.centos.noarch                     36/49
    default:
    default:   Verifying  : 1:nginx-mod-http-image-filter-1.16.1-1.el7.x86_64          37/49
    default:
    default:   Verifying  : perl-Encode-2.51-7.el7.x86_64                              38/49
    default:
    default:   Verifying  : perl-Pod-Perldoc-3.20-4.el7.noarch                         39/49
    default:
    default:   Verifying  : perl-podlators-2.5.1-3.el7.noarch                          40/49
    default:
    default:   Verifying  : libXau-1.0.8-2.1.el7.x86_64                                41/49
    default:
    default:   Verifying  : perl-File-Path-2.09-2.el7.noarch                           42/49
    default:
    default:   Verifying  : perl-threads-1.87-4.el7.x86_64                             43/49
    default:
    default:   Verifying  : gperftools-libs-2.6.1-1.el7.x86_64                         44/49
    default:
    default:   Verifying  : perl-Filter-1.49-3.el7.x86_64                              45/49
    default:
    default:   Verifying  : perl-Getopt-Long-2.40-3.el7.noarch                         46/49
    default:
    default:   Verifying  : perl-Text-ParseWords-3.29-4.el7.noarch                     47/49
    default:
    default:   Verifying  : 4:perl-5.16.3-294.el7_6.x86_64                             48/49
    default:
    default:   Verifying  : gd-2.0.35-26.el7.x86_64                                    49/49
    default:
    default:
    default: Installed:
    default:   nginx.x86_64 1:1.16.1-1.el7
    default:
    default: Dependency Installed:
    default:   centos-indexhtml.noarch 0:7-9.el7.centos
    default:   centos-logos.noarch 0:70.0.6-3.el7.centos
    default:   dejavu-fonts-common.noarch 0:2.33-6.el7
    default:   dejavu-sans-fonts.noarch 0:2.33-6.el7
    default:   fontconfig.x86_64 0:2.13.0-4.3.el7
    default:   fontpackages-filesystem.noarch 0:1.44-8.el7
    default:   gd.x86_64 0:2.0.35-26.el7
    default:   gperftools-libs.x86_64 0:2.6.1-1.el7
    default:   libX11.x86_64 0:1.6.7-2.el7
    default:   libX11-common.noarch 0:1.6.7-2.el7
    default:   libXau.x86_64 0:1.0.8-2.1.el7
    default:   libXpm.x86_64 0:3.5.12-1.el7
    default:   libjpeg-turbo.x86_64 0:1.2.90-8.el7
    default:   libxcb.x86_64 0:1.13-1.el7
    default:   nginx-all-modules.noarch 1:1.16.1-1.el7
    default:   nginx-filesystem.noarch 1:1.16.1-1.el7
    default:   nginx-mod-http-image-filter.x86_64 1:1.16.1-1.el7
    default:   nginx-mod-http-perl.x86_64 1:1.16.1-1.el7
    default:   nginx-mod-http-xslt-filter.x86_64 1:1.16.1-1.el7
    default:   nginx-mod-mail.x86_64 1:1.16.1-1.el7
    default:   nginx-mod-stream.x86_64 1:1.16.1-1.el7
    default:   perl.x86_64 4:5.16.3-294.el7_6
    default:   perl-Carp.noarch 0:1.26-244.el7
    default:   perl-Encode.x86_64 0:2.51-7.el7
    default:   perl-Exporter.noarch 0:5.68-3.el7
    default:   perl-File-Path.noarch 0:2.09-2.el7
    default:   perl-File-Temp.noarch 0:0.23.01-3.el7
    default:   perl-Filter.x86_64 0:1.49-3.el7
    default:   perl-Getopt-Long.noarch 0:2.40-3.el7
    default:   perl-HTTP-Tiny.noarch 0:0.033-3.el7
    default:   perl-PathTools.x86_64 0:3.40-5.el7
    default:   perl-Pod-Escapes.noarch 1:1.04-294.el7_6
    default:   perl-Pod-Perldoc.noarch 0:3.20-4.el7
    default:   perl-Pod-Simple.noarch 1:3.28-4.el7
    default:   perl-Pod-Usage.noarch 0:1.63-3.el7
    default:   perl-Scalar-List-Utils.x86_64 0:1.27-248.el7
    default:   perl-Socket.x86_64 0:2.010-4.el7
    default:   perl-Storable.x86_64 0:2.45-3.el7
    default:   perl-Text-ParseWords.noarch 0:3.29-4.el7
    default:   perl-Time-HiRes.x86_64 4:1.9725-3.el7
    default:   perl-Time-Local.noarch 0:1.2300-2.el7
    default:   perl-constant.noarch 0:1.27-2.el7
    default:   perl-libs.x86_64 4:5.16.3-294.el7_6
    default:   perl-macros.x86_64 4:5.16.3-294.el7_6
    default:   perl-parent.noarch 1:0.225-244.el7
    default:   perl-podlators.noarch 0:2.5.1-3.el7
    default:   perl-threads.x86_64 0:1.87-4.el7
    default:   perl-threads-shared.x86_64 0:1.43-6.el7
    default:
    default: Complete!
    default: Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
    default: success
    default: success
PS C:\vagrant\my_centos>

Ansible

Ansible を使用してプロビジョニングします。エクスターナルスクリプトと同様に Vagrantfile とは別にプレイブックファイルを用意します。

注釈

プロビジョニング対象の仮想マシンに Ansible がインストールされていないときは自動でインストールされます。

プロビジョニングで実行するプレイブックファイルです。

PS C:\vagrant\my_centos> cat .\provision\nginx.yml
---
- hosts: all
  become: yes

  tasks:
  - name: install Nginx
    yum:
      name: nginx
      state: latest
    notify:
    - nginx restart
  - name: firewalld start
    systemd:
      name: firewalld
      enabled: yes
      state: started
  - name: firewalld enable http
    firewalld:
      service: http
      immediate: yes
      permanent: yes
      state: enabled
  handlers:
  - name: nginx service restarted
    systemd:
      name: nginx
      enabled: yes
      state: restarted
    listen:
    - nginx restart
PS C:\vagrant\my_centos>
config.vm.provision "ansible_local" do |ansible|
  ansible.playbook = "./provision/nginx.yml"
end

Vagrantfile の全体です。

Vagrant.configure("2") do |config|
  config.vm.box = "centos/7"
  config.vm.network "public_network", mac: "080027000001"
  config.vm.hostname = "web-sv"
  config.vm.provider "virtualbox" do |vb|
    vb.gui = true
    vb.name = "nginx"
    vb.memory = "4096"
    vb.cpus = 2
    vb.customize [
      "modifyvm", :id,
      "--ioapic", "on",
      "--graphicscontroller", "vmsvga"
    ]
  end
  config.vm.provision "ansible_local" do |ansible|
    ansible.playbook = "./provision/nginx.yml"
  end
end

実行結果です。

PS C:\vagrant\my_centos> vagrant up                                                                                   Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'centos/7'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'centos/7' version '1905.1' is up to date...
==> default: Setting the name of the VM: nginx
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: bridged
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default:
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default:
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: No guest additions were detected on the base box for this VM! Guest
    default: additions are required for forwarded ports, shared folders, host only
    default: networking, and more. If SSH fails on this machine, please install
    default: the guest additions and repackage the box to continue.
    default:
    default: This is not an error message; everything may continue to work properly,
    default: in which case you may ignore this message.
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Rsyncing folder: /cygdrive/c/vagrant/my_centos/ => /vagrant
==> default: Running provisioner: ansible_local...
    default: Installing Ansible...
Vagrant has automatically selected the compatibility mode '2.0'
according to the Ansible version installed (2.9.3).

Alternatively, the compatibility mode can be specified in your Vagrantfile:
https://www.vagrantup.com/docs/provisioning/ansible_common.html#compatibility_mode
    default: Running ansible-playbook...

PLAY [all] *********************************************************************

TASK [Gathering Facts] *********************************************************
ok: [default]

TASK [install Nginx] ***********************************************************
changed: [default]

TASK [firewalld start] *********************************************************
changed: [default]

TASK [firewalld enable http] ***************************************************
changed: [default]

RUNNING HANDLER [nginx service restarted] **************************************
changed: [default]

PLAY RECAP *********************************************************************
default                    : ok=5    changed=4    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

PS C:\vagrant\my_centos>