У меня очень странное поведение, когда я создаю бродячую упаковочную коробку виртуального ящика. Я использую коробку с vagrant, чтобы проверить свои модули марионеток перед их развертыванием в производственной среде. Я хотел бы использовать puppet-agent на ubuntu-16.04 для сервера puppet5. Вывод PACKER_LOG=1 packer build ubuntu-16.04.json
, как вы можете видеть в файле журнала ниже, но когда я вхожу в бродячее окно, у меня только puppet 3.8.x
и puppet-common
и никаких следов puppet-agent
.
Я удалил старую коробку, создал новый бродягу, чтобы убедиться, что я использую текущую коробку, но, к сожалению, я не смог решить эту проблему.
Так что либо я делаю apt-get update && apt-get install puppet-agent
внутри коробки, либо я устанавливаю его с помощью vagrant с помощью поставщика оболочки, но я бы хотел управлять этим с помощью упаковщика.
Вот соответствующая часть вывода журнала:
==> virtualbox-iso: Provisioning with shell script: scripts/puppet.sh
2018/05/07 05:59:27 ui: ==> virtualbox-iso: Provisioning with shell script: scripts/puppet.sh
2018/05/07 05:59:27 packer: 2018/05/07 05:59:27 Opening scripts/puppet.sh for reading
2018/05/07 05:59:27 packer: 2018/05/07 05:59:27 [INFO] 181 bytes written for 'uploadData'
2018/05/07 05:59:27 [INFO] 181 bytes written for 'uploadData'
2018/05/07 05:59:27 packer: 2018/05/07 05:59:27 [DEBUG] Opening new ssh session
2018/05/07 05:59:27 packer: 2018/05/07 05:59:27 [DEBUG] Starting remote scp process: scp -vt /tmp
2018/05/07 05:59:27 packer: 2018/05/07 05:59:27 [DEBUG] Started SCP session, beginning transfers...
2018/05/07 05:59:27 packer: 2018/05/07 05:59:27 [DEBUG] scp: Uploading script_8159.sh: perms=C0644 size=181
2018/05/07 05:59:27 packer: 2018/05/07 05:59:27 [DEBUG] SCP session complete, closing stdin pipe.
2018/05/07 05:59:27 packer: 2018/05/07 05:59:27 [DEBUG] Waiting for SSH session to complete.
2018/05/07 05:59:27 packer: 2018/05/07 05:59:27 [DEBUG] scp stderr (length 31): Sink: C0644 181 script_8159.sh
2018/05/07 05:59:27 packer: 2018/05/07 05:59:27 [DEBUG] Opening new ssh session
2018/05/07 05:59:27 packer: 2018/05/07 05:59:27 [DEBUG] starting remote command: chmod 0755 /tmp/script_8159.sh
2018/05/07 05:59:27 [INFO] RPC client: Communicator ended with: 0
2018/05/07 05:59:27 [INFO] RPC endpoint: Communicator ended with: 0
2018/05/07 05:59:27 packer: 2018/05/07 05:59:27 [INFO] RPC endpoint: Communicator ended with: 0
2018/05/07 05:59:27 packer: 2018/05/07 05:59:27 [INFO] RPC client: Communicator ended with: 0
2018/05/07 05:59:27 packer: 2018/05/07 05:59:27 [DEBUG] Opening new ssh session
2018/05/07 05:59:27 packer: 2018/05/07 05:59:27 [DEBUG] starting remote command: echo 'vagrant' | PACKER_BUILDER_TYPE='virtualbox-iso' PACKER_BUILD_NAME='virtualbox-iso' PACKER_HTTP_ADDR='10.0.2.2:8421' sudo -E -S bash '/tmp/script_8159.sh'
2018/05/07 05:59:27 ui: virtualbox-iso: --2018-05-07 05:59:27-- https://apt.puppetlabs.com/puppet5-release-xenial.deb
virtualbox-iso: --2018-05-07 05:59:27-- https://apt.puppetlabs.com/puppet5-release-xenial.deb
2018/05/07 05:59:28 ui: virtualbox-iso: Resolving apt.puppetlabs.com (apt.puppetlabs.com)... 52.85.173.69, 52.85.173.15, 52.85.173.19, ...
virtualbox-iso: Resolving apt.puppetlabs.com (apt.puppetlabs.com)... 52.85.173.69, 52.85.173.15, 52.85.173.19, ...
virtualbox-iso: Connecting to apt.puppetlabs.com (apt.puppetlabs.com)|52.85.173.69|:443... connected.
2018/05/07 05:59:28 ui: virtualbox-iso: Connecting to apt.puppetlabs.com (apt.puppetlabs.com)|52.85.173.69|:443... connected.
2018/05/07 05:59:28 ui: virtualbox-iso: HTTP request sent, awaiting response... 200 OK
virtualbox-iso: HTTP request sent, awaiting response... 200 OK
virtualbox-iso: Length: 6850 (6.7K) [application/x-debian-package]
2018/05/07 05:59:28 ui: virtualbox-iso: Length: 6850 (6.7K) [application/x-debian-package]
virtualbox-iso: Saving to: ‘puppet5-release-xenial.deb’
2018/05/07 05:59:28 ui: virtualbox-iso: Saving to: ‘puppet5-release-xenial.deb’
virtualbox-iso:
2018/05/07 05:59:28 ui: virtualbox-iso:
virtualbox-iso: 0K ...... 100% 29.0M=0s
2018/05/07 05:59:28 ui: virtualbox-iso: 0K ...... 100% 29.0M=0s
virtualbox-iso:
2018/05/07 05:59:28 ui: virtualbox-iso:
2018/05/07 05:59:28 ui: virtualbox-iso: 2018-05-07 05:59:28 (29.0 MB/s) - ‘puppet5-release-xenial.deb’ saved [6850/6850]
virtualbox-iso: 2018-05-07 05:59:28 (29.0 MB/s) - ‘puppet5-release-xenial.deb’ saved [6850/6850]
virtualbox-iso:
2018/05/07 05:59:28 ui: virtualbox-iso:
virtualbox-iso: Selecting previously unselected package puppet5-release.
2018/05/07 05:59:28 ui: virtualbox-iso: Selecting previously unselected package puppet5-release.
virtualbox-iso: (Reading database ... 64089 files and directories currently installed.)
2018/05/07 05:59:28 ui: virtualbox-iso: (Reading database ... 64089 files and directories currently installed.)
2018/05/07 05:59:28 ui: virtualbox-iso: Preparing to unpack puppet5-release-xenial.deb ...
virtualbox-iso: Preparing to unpack puppet5-release-xenial.deb ...
virtualbox-iso: Unpacking puppet5-release (5.0.0-1xenial) ...
2018/05/07 05:59:28 ui: virtualbox-iso: Unpacking puppet5-release (5.0.0-1xenial) ...
2018/05/07 05:59:28 ui: virtualbox-iso: Setting up puppet5-release (5.0.0-1xenial) ...
virtualbox-iso: Setting up puppet5-release (5.0.0-1xenial) ...
virtualbox-iso: Ign:1 http://apt.puppetlabs.com xenial InRelease
2018/05/07 05:59:29 ui: virtualbox-iso: Ign:1 http://apt.puppetlabs.com xenial InRelease
virtualbox-iso: Get:2 http://apt.puppetlabs.com xenial Release [57.5 kB]
2018/05/07 05:59:29 ui: virtualbox-iso: Get:2 http://apt.puppetlabs.com xenial Release [57.5 kB]
2018/05/07 05:59:29 ui: virtualbox-iso: Hit:3 http://security.ubuntu.com/ubuntu xenial-security InRelease
virtualbox-iso: Hit:3 http://security.ubuntu.com/ubuntu xenial-security InRelease
2018/05/07 05:59:29 ui: virtualbox-iso: Hit:4 http://de.archive.ubuntu.com/ubuntu xenial InRelease
virtualbox-iso: Hit:4 http://de.archive.ubuntu.com/ubuntu xenial InRelease
virtualbox-iso: Get:5 http://apt.puppetlabs.com xenial Release.gpg [836 B]
2018/05/07 05:59:29 ui: virtualbox-iso: Get:5 http://apt.puppetlabs.com xenial Release.gpg [836 B]
virtualbox-iso: Hit:6 http://de.archive.ubuntu.com/ubuntu xenial-updates InRelease
2018/05/07 05:59:29 ui: virtualbox-iso: Hit:6 http://de.archive.ubuntu.com/ubuntu xenial-updates InRelease
2018/05/07 05:59:29 ui: virtualbox-iso: Hit:7 http://de.archive.ubuntu.com/ubuntu xenial-backports InRelease
virtualbox-iso: Hit:7 http://de.archive.ubuntu.com/ubuntu xenial-backports InRelease
virtualbox-iso: Get:8 http://apt.puppetlabs.com xenial/puppet5 amd64 Packages [15.5 kB]
2018/05/07 05:59:30 ui: virtualbox-iso: Get:8 http://apt.puppetlabs.com xenial/puppet5 amd64 Packages [15.5 kB]
virtualbox-iso: Get:9 http://apt.puppetlabs.com xenial/puppet5 i386 Packages [13.4 kB]
2018/05/07 05:59:30 ui: virtualbox-iso: Get:9 http://apt.puppetlabs.com xenial/puppet5 i386 Packages [13.4 kB]
virtualbox-iso: Get:10 http://apt.puppetlabs.com xenial/puppet5 all Packages [7,432 B]
2018/05/07 05:59:30 ui: virtualbox-iso: Get:10 http://apt.puppetlabs.com xenial/puppet5 all Packages [7,432 B]
2018/05/07 05:59:31 ui: virtualbox-iso: Fetched 94.6 kB in 1s (51.7 kB/s)
virtualbox-iso: Fetched 94.6 kB in 1s (51.7 kB/s)
2018/05/07 05:59:33 ui: virtualbox-iso: Reading package lists...
virtualbox-iso: Reading package lists...
virtualbox-iso: Reading package lists...
2018/05/07 05:59:34 ui: virtualbox-iso: Reading package lists...
2018/05/07 05:59:34 ui: virtualbox-iso: Building dependency tree...
virtualbox-iso: Building dependency tree...
2018/05/07 05:59:34 ui: virtualbox-iso: Reading state information...
virtualbox-iso: Reading state information...
2018/05/07 05:59:34 ui: virtualbox-iso: The following NEW packages will be installed:
virtualbox-iso: The following NEW packages will be installed:
2018/05/07 05:59:34 ui: virtualbox-iso: puppet-agent
virtualbox-iso: puppet-agent
2018/05/07 05:59:35 ui: virtualbox-iso: 0 upgraded, 1 newly installed, 0 to remove and 44 not upgraded.
virtualbox-iso: 0 upgraded, 1 newly installed, 0 to remove and 44 not upgraded.
2018/05/07 05:59:35 ui: virtualbox-iso: Need to get 17.2 MB of archives.
virtualbox-iso: Need to get 17.2 MB of archives.
2018/05/07 05:59:35 ui: virtualbox-iso: After this operation, 96.1 MB of additional disk space will be used.
virtualbox-iso: After this operation, 96.1 MB of additional disk space will be used.
2018/05/07 05:59:35 ui: virtualbox-iso: Get:1 http://apt.puppetlabs.com xenial/puppet5 amd64 puppet-agent amd64 5.5.1-1xenial [17.2 MB]
virtualbox-iso: Get:1 http://apt.puppetlabs.com xenial/puppet5 amd64 puppet-agent amd64 5.5.1-1xenial [17.2 MB]
virtualbox-iso: debconf: unable to initialize frontend: Dialog
2018/05/07 05:59:42 ui: virtualbox-iso: debconf: unable to initialize frontend: Dialog
2018/05/07 05:59:42 ui: virtualbox-iso: debconf: (Dialog frontend will not work on a dumb terminal, an emacs shell buffer, or without a controlling terminal.)
virtualbox-iso: debconf: (Dialog frontend will not work on a dumb terminal, an emacs shell buffer, or without a controlling terminal.)
virtualbox-iso: debconf: falling back to frontend: Readline
2018/05/07 05:59:42 ui: virtualbox-iso: debconf: falling back to frontend: Readline
2018/05/07 05:59:42 ui: virtualbox-iso: debconf: unable to initialize frontend: Readline
virtualbox-iso: debconf: unable to initialize frontend: Readline
virtualbox-iso: debconf: (This frontend requires a controlling tty.)
2018/05/07 05:59:42 ui: virtualbox-iso: debconf: (This frontend requires a controlling tty.)
2018/05/07 05:59:42 ui: virtualbox-iso: debconf: falling back to frontend: Teletype
virtualbox-iso: debconf: falling back to frontend: Teletype
2018/05/07 05:59:42 ui: virtualbox-iso: dpkg-preconfigure: unable to re-open stdin:
virtualbox-iso: dpkg-preconfigure: unable to re-open stdin:
2018/05/07 05:59:43 ui: virtualbox-iso: Fetched 17.2 MB in 7s (2,295 kB/s)
virtualbox-iso: Fetched 17.2 MB in 7s (2,295 kB/s)
2018/05/07 05:59:43 ui: virtualbox-iso: Selecting previously unselected package puppet-agent.
virtualbox-iso: Selecting previously unselected package puppet-agent.
2018/05/07 05:59:43 ui: virtualbox-iso: (Reading database ... 64094 files and directories currently installed.)
virtualbox-iso: (Reading database ... 64094 files and directories currently installed.)
2018/05/07 05:59:43 ui: virtualbox-iso: Preparing to unpack .../puppet-agent_5.5.1-1xenial_amd64.deb ...
virtualbox-iso: Preparing to unpack .../puppet-agent_5.5.1-1xenial_amd64.deb ...
2018/05/07 05:59:43 ui: virtualbox-iso: Unpacking puppet-agent (5.5.1-1xenial) ...
virtualbox-iso: Unpacking puppet-agent (5.5.1-1xenial) ...
virtualbox-iso: Processing triggers for libc-bin (2.23-0ubuntu10) ...
2018/05/07 06:00:19 ui: virtualbox-iso: Processing triggers for libc-bin (2.23-0ubuntu10) ...
virtualbox-iso: Setting up puppet-agent (5.5.1-1xenial) ...
2018/05/07 06:00:19 ui: virtualbox-iso: Setting up puppet-agent (5.5.1-1xenial) ...
2018/05/07 06:00:20 ui: virtualbox-iso: Created symlink from /etc/systemd/system/multi-user.target.wants/puppet.service to /lib/systemd/system/puppet.service.
virtualbox-iso: Created symlink from /etc/systemd/system/multi-user.target.wants/puppet.service to /lib/systemd/system/puppet.service.
virtualbox-iso: Created symlink from /etc/systemd/system/multi-user.target.wants/mcollective.service to /lib/systemd/system/mcollective.service.
2018/05/07 06:00:20 ui: virtualbox-iso: Created symlink from /etc/systemd/system/multi-user.target.wants/mcollective.service to /lib/systemd/system/mcollective.service.
virtualbox-iso: Created symlink from /etc/systemd/system/multi-user.target.wants/pxp-agent.service to /lib/systemd/system/pxp-agent.service.
2018/05/07 06:00:20 ui: virtualbox-iso: Created symlink from /etc/systemd/system/multi-user.target.wants/pxp-agent.service to /lib/systemd/system/pxp-agent.service.
2018/05/07 06:00:21 ui: virtualbox-iso: Removed symlink /etc/systemd/system/multi-user.target.wants/pxp-agent.service.
virtualbox-iso: Removed symlink /etc/systemd/system/multi-user.target.wants/pxp-agent.service.
2018/05/07 06:00:21 ui: virtualbox-iso: Processing triggers for libc-bin (2.23-0ubuntu10) ...
virtualbox-iso: Processing triggers for libc-bin (2.23-0ubuntu10) ...
virtualbox-iso: Reading package lists...
2018/05/07 06:00:22 ui: virtualbox-iso: Reading package lists...
virtualbox-iso: Building dependency tree...
2018/05/07 06:00:22 ui: virtualbox-iso: Building dependency tree...
2018/05/07 06:00:22 ui: virtualbox-iso: Reading state information...
virtualbox-iso: Reading state information...
virtualbox-iso: 0 upgraded, 0 newly installed, 0 to remove and 44 not upgraded.
2018/05/07 06:00:22 ui: virtualbox-iso: 0 upgraded, 0 newly installed, 0 to remove and 44 not upgraded.
2018/05/07 06:00:22 [INFO] 2950 bytes written for 'stdout'
2018/05/07 06:00:22 [INFO] 971 bytes written for 'stderr'
2018/05/07 06:00:22 [INFO] RPC client: Communicator ended with: 0
2018/05/07 06:00:22 [INFO] RPC endpoint: Communicator ended with: 0
2018/05/07 06:00:22 packer: 2018/05/07 06:00:22 [INFO] RPC endpoint: Communicator ended with: 0
2018/05/07 06:00:22 packer: 2018/05/07 06:00:22 [INFO] 2950 bytes written for 'stdout'
2018/05/07 06:00:22 packer: 2018/05/07 06:00:22 [INFO] 971 bytes written for 'stderr'
2018/05/07 06:00:22 packer: 2018/05/07 06:00:22 [INFO] RPC client: Communicator ended with: 0
2018/05/07 06:00:22 packer: 2018/05/07 06:00:22 [DEBUG] Opening new ssh session
2018/05/07 06:00:22 packer: 2018/05/07 06:00:22 [DEBUG] starting remote command: rm -f /tmp/script_8159.sh
2018/05/07 06:00:23 packer: 2018/05/07 06:00:23 [INFO] RPC endpoint: Communicator ended with: 0
2018/05/07 06:00:23 [INFO] RPC client: Communicator ended with: 0
2018/05/07 06:00:23 [INFO] RPC endpoint: Communicator ended with: 0
2018/05/07 06:00:23 packer: 2018/05/07 06:00:23 [INFO] RPC client: Communicator ended with: 0
==> virtualbox-iso: Provisioning with shell script: scripts/cleanup.sh
вот мой файл json:
{
"variables": {
"vm_name": "ubuntu-16.04",
"disk_size": "40960",
"http_directory": "http",
"hostname": "vagrant",
"ssh_fullname": "vagrant",
"ssh_username": "vagrant",
"ssh_password": "vagrant",
"ssh_wait_timeout": "10000s",
"iso_url": "http://releases.ubuntu.com/16.04/ubuntu-16.04.4-server-amd64.iso",
"iso_checksum_url": "http://releases.ubuntu.com/16.04/SHA256SUMS",
"iso_checksum_type": "sha256",
"preseed" : "preseed.cfg"
},
"builders": [{
"type": "virtualbox-iso",
"headless": true,
"boot_wait": "10s",
"disk_size": "{{user `disk_size`}}",
"http_directory": "http",
"guest_os_type": "Ubuntu_64",
"iso_url": "{{user `iso_url`}}",
"iso_checksum_url": "{{user `iso_checksum_url`}}",
"iso_checksum_type": "{{user `iso_checksum_type`}}",
"ssh_username": "{{user `ssh_username`}}",
"ssh_password": "{{user `ssh_password`}}",
"ssh_wait_timeout": "{{user `ssh_wait_timeout`}}",
"shutdown_command": "echo '{{user `ssh_password`}}' | sudo -S shutdown -P now",
"guest_additions_path": "VBoxGuestAdditions_{{.Version}}.iso",
"virtualbox_version_file": ".vbox_version",
"vboxmanage": [
[ "modifyvm", "{{.Name}}", "--cpus", "2" ],
[ "modifyvm", "{{.Name}}", "--memory", "1024" ],
[ "modifyvm", "{{.Name}}", "--nictype1", "virtio" ],
[ "modifyvm", "{{.Name}}", "--natdnsproxy1", "on" ],
[ "modifyvm", "{{.Name}}", "--natdnshostresolver1", "on" ]
],
"boot_command": [
"<enter><wait>",
"<f6><esc>",
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
"<bs><bs><bs>",
"/install/vmlinuz noapic ",
"initrd=/install/initrd.gz ",
"auto preseed/url=http://{{.HTTPIP}}:{{.HTTPPort}}/preseed.cfg ",
"auto-install/enable=true ",
"debconf/frontend=noninteractive<wait> ",
"debian-installer={{ user `locale` }} auto locale={{ user `locale` }} kbd-chooser/method=de ",
"fb=false debconf/frontend=noninteractive ",
"console-setup/ask_detect=false ",
"keyboard-configuration/modelcode=pc105 ",
"keyboard-configuration/layout=DE ",
"keyboard-configuration/variant=DE ",
"hostname={{user `hostname`}} ",
"passwd/user-fullname={{ user `ssh_fullname` }} ",
"passwd/user-password={{ user `ssh_password` }} ",
"passwd/user-password-again={{ user `ssh_password` }} ",
"passwd/username={{ user `ssh_username` }} ",
"-- <wait>",
"<enter>"
]
}],
"provisioners": [
{
"type": "shell",
"pause_before": "30s",
"execute_command": "echo '{{ user `ssh_password` }}' | {{.Vars}} sudo -E -S bash '{{.Path}}'",
"scripts": [
"scripts/network.sh",
"scripts/config.sh",
"scripts/vagrant.sh",
"scripts/virtualbox.sh",
"scripts/puppet.sh",
"scripts/cleanup.sh"
]
}
],
"post-processors": [
{
"type": "vagrant",
"override": {
"virtualbox": {
"output": "ubuntu-16-04-vagrant-vbox.box"
}
}
}
]
}
И вот как я устанавливаю puppet-agent
с scripts/puppet.sh
:
#!/bin/bash -eux
wget https://apt.puppetlabs.com/puppet5-release-xenial.deb
dpkg -i puppet5-release-xenial.deb
apt-get update
apt-get install puppet-agent -y
gem install r10k
Если вам нужно содержимое других скриптов и файл preseed.cfg
, я также опубликую их.
Спасибо за вашу помощь.