Using packer to create a vagrant qemu/kvm box - vagrant

I am attempting to build a vagrant .box using the qemu/kvm hypervisor using packer. I am using the vagrant plugin vagrant-libvirt.
In my packer base.json file, I am using the vagrant post-processor, like
"post-processors": [
{
"type": "vagrant",
"output": "output/my-ubuntu_14.04_packer.box"
}
],
When I build the box however, I get this error in the logs:
2015/12/22 20:11:57 ui error: Build 'qemu' errored: 1 error(s) occurred:
* Post-processor failed: Unknown artifact type, can't build box: transcend.qemu
I've looked in to this issue, and it does seem to be caused by that post-processor configuration. For example, according to the conversation here, qemu did not support the vagrant post processor at that time. However, looking at this it should work now that this pull request is merged.
In fact, the documentation for the vagrant post-processor seems lists qemu as a supported provider.

I believe this is because I am currently using Packer v0.6.0 (released May 2, 2014). The vagrant post-processor wasn't supported until Packer v0.7.2 (released Oct 28, 2014), so an upgrade would be necessary to achieve this.

Related

Terraform azurerm_virtual_machine_extension error "extension operations are disallowed"

I have written a Terraform template that creates an Azure Windows VM. I need to configure the VM to Enable PowerShell Remoting for the release pipeline to be able to execute Powershell scripts. After the VM is created I can RDP to the VM and do everything I need to do to enable Powershell remoting, however, it would be ideal if I could script all of that so it could be executed in a Release pipeline. There are two things that prevent that.
The first, and the topic of this question is, that I have to run "WinRM quickconfig". I have the template working such that when I do RDP to the VM, after creation, that when I run "WinRM quickconfig" I receive the following responses:
WinRM service is already running on this machine.
WinRM is not set up to allow remote access to this machine for management.
The following changes must be made:
Configure LocalAccountTokenFilterPolicy to grant administrative rights remotely to local users.
Make these changes [y/n]?
I want to configure the VM in Terraform so LocalAccountTokenFilterPolicy is set and it becomes unnecessary to RDP to the VM to run "WinRM quickconfig". After some research it appeared I might be able to do that using the resource azure_virtual_machine_extension. I add this to my template:
resource "azurerm_virtual_machine_extension" "vmx" {
name = "hostname"
location = "${var.location}"
resource_group_name = "${var.vm-resource-group-name}"
virtual_machine_name = "${azurerm_virtual_machine.vm.name}"
publisher = "Microsoft.Azure.Extensions"
type = "CustomScript"
type_handler_version = "2.0"
settings = <<SETTINGS
{
# "commandToExecute": "powershell Set-ItemProperty -Path 'HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System' -Name 'LocalAccountTokenFilterPolicy' -Value 1 -Force"
}
SETTINGS
}
When I apply this, I get the error:
Error: compute.VirtualMachineExtensionsClient#CreateOrUpdate: Failure sending request: StatusCode=0 -- Original Error: autorest/azure: Service returned an error. Status=<nil> Code="OperationNotAllowed" Message="This operation cannot be performed when extension operations are disallowed. To allow, please ensure VM Agent is installed on the VM and the osProfile.allowExtensionOperations property is true."
I couldn't find any Terraform documentation that addresses how to set the allowExtensionOperations property to true. On a whim, I tried adding the property "allow_extension_operations" to the os_profile block in the azurerm_virtual_machine resource but it is rejected as an invalid property. I also tried adding it to the os_profile_windows_config block and isn't valid there either.
I found a statement on Microsoft's documentation regarding the osProfile.allowExtensionOperations property that says:
"This may only be set to False when no extensions are present on the virtual machine."
https://learn.microsoft.com/en-us/dotnet/api/microsoft.azure.management.compute.models.osprofile.allowextensionoperations?view=azure-dotnet
This implies to me that the property is True by default but it doesn't actually say that and it certainly isn't acting like that. Is there a way in Terraform to set osProfile.alowExtensionOperations to true?
Running into the same issue adding extensions using Terraform, i created a Windows 2016 custom image,
provider "azurerm" version ="2.0.0"
Terraform 0.12.24
Terraform apply error:
compute.VirtualMachineExtensionsClient#CreateOrUpdate: Failure sending request: StatusCode=0
-- Original Error: autorest/azure: Service returned an error.
Status=<nil>
Code="OperationNotAllowed"
Message="This operation cannot be performed when extension operations are disallowed. To allow, please ensure VM Agent is installed on the VM and the osProfile.allowExtensionOperations property is true."
I ran into same error, possible solution depends on 2 things here.
You have to pass provider "azurerm" version ="2.5.0 and you have to pass os_profile_windows_config (see below) parameter in virtual machine resource as well. So, that terraform will consider the extensions that your are passing. This fixed my errors.
os_profile_windows_config {
provision_vm_agent = true
}

Icinga2 does not start because he could not load library "db_ido_mysql"

Here is the Error:
root#taurus:/etc/icinga2/features-available# service icinga2 checkconfig
* checking Icinga2 configuration
information/cli: Icinga application loader (version: r2.7.2-1)
information/cli: Loading configuration file(s).
critical/config: Error: Error while evaluating expression: Could not load library 'libdb_ido_mysql.so.2.7.2': libdb_ido_mysql.so.2.7.2: cannot open shared object file: No such file or directory
Location: in /etc/icinga2/features-enabled/ido-mysql.conf: 6:1-6:22
/etc/icinga2/features-enabled/ido-mysql.conf(4): */
/etc/icinga2/features-enabled/ido-mysql.conf(5):
/etc/icinga2/features-enabled/ido-mysql.conf(6): library "db_ido_mysql"
^^^^^^^^^^^^^^^^^^^^^^
/etc/icinga2/features-enabled/ido-mysql.conf(7):
/etc/icinga2/features-enabled/ido-mysql.conf(8): object IdoMysqlConnection "ido-mysql" {
* checking Icinga2 configuration. Check '/var/log/icinga2/startup.log' for details.
root#taurus:/etc/icinga2/features-available# icinga2 feature list
Disabled features: command compatlog debuglog gelf graphite influxdb livestatus opentsdb perfdata statusdata syslog
Enabled features: api checker ido-mysql ido-pgsql mainlog notification
Does anybody know what i did wrong during the installation?
there were no problems, i dont get the answer.
Do you want to use Icingaweb2 with your Icinga2 installation? Then you have to install the
icinga2-ido-mysql
Package for your distribution and configure it. Here you can find a step by step instruction on how to install and configure it. If not, disable the following features:
ido-mysql ido-pgsql
Regards,
Jan

Gradle Docker plugin broken pipe on osx

Hi I try to use this awesome Gradle plugin: https://github.com/bmuschko/gradle-docker-plugin
I use the following URL obtained from my docker-machine / kitematic installation on osx:
docker-machine url default
tcp://192.168.99.100:2376
However using:
url = "tcp://192.168.99.100:2376"
results in the error:
org.apache.http.conn.UnsupportedSchemeException: tcp protocol is not supported
When I change the tcp to httpI get a different error:
INFO org.apache.http.impl.execchain.RetryExec - I/O exception (java.net.SocketException) caught when processing request: Broken pipe
[pool-4-thread-1] ERROR com.github.dockerjava.core.async.ResultCallbackTemplate - Error during callback
org.apache.http.client.ClientProtocolException
in case the gradle dockerBuildImage task is run.
But manually building the Dockerfile created by gradle works without any problems.
The following code can be used to replicate the problem. https://github.com/geoHeil/lab04/blob/master/build.gradle
Docker-machine enables TLS by default. I Switching to the TLSmode should be a good solution:
url = 'https://192.168.59.103:2376'
certPath = new File(System.properties['user.home'], '.boot2docker/certs/boot2docker-vm')

packer building amazon-chroot - simple example does not work

I'm trying to build an Amazon AMI centos using Packer. I am using the amazon-chroot builder.
The ami exists, but I am getting the build error
[root#ip-10-32-11-16 retel-base]# packer build retel-base.json
amazon-chroot output will be in this color.
==> amazon-chroot: Gathering information about this EC2 instance...
==> amazon-chroot: Inspecting the source AMI...
==> amazon-chroot: Couldn't find root device!
Build 'amazon-chroot' errored: Couldn't find root device!
==> Some builds didn't complete successfully and had errors:
--> amazon-chroot: Couldn't find root device!
==> Builds finished but no artifacts were created.
cat retel-base.json
{
"variables": {
"ACCESS_KEY_ID": "{{env `ACCESS_KEY_ID`}}",
"SECRET_ACCESS_KEY": "{{env `SECRET_ACCESS_KEY`}}"
},
"builders": [{
"type": "amazon-chroot",
"access_key": "{{user `ACCESS_KEY_ID`}}",
"secret_key": "{{user `SECRET_ACCESS_KEY`}}",
"source_ami":"ami-a40df4cc",
"ami_name": "base image built with packer {{timestamp}}"
}]
}
I think this might be to do with a mismatch between the name of the root device and the block device mapping.
In the official CentOS AMIs, the root device is named /dev/sda but the block device mapping only lists /dev/sda1, which is apparently a partition on the root device.
The Aminator by Netflix has a similar problem with partitioned volumes: https://github.com/Netflix/aminator/issues/129

Vagrant plugin doesn't work in Jenkins

I install vagrant plugin in Jenkins (ubuntu12.04) and when I try to build, I am getting the below errors.
Started by user anonymous
Building in workspace /var/lib/jenkins/jobs/testvagrant/workspace
Running Vagrant with version: 1.0.2.dev
FATAL: (ArgumentError) wrong number of arguments calling initialize (1 for 0)
org.jruby.exceptions.RaiseException: (ArgumentError) wrong number of arguments calling initialize (1 for 0)
at RUBY.initialize(/var/lib/jenkins/plugins/vagrant/WEB-INF/classes/vendor/gems/jruby/1.8/bundler/gems/vagrant-8a5b1ad0d1ef/lib/vagrant/environment.rb:77)
at RUBY.setup(/var/lib/jenkins/plugins/vagrant/WEB-INF/classes/models/vagrant_wrapper.rb:63)
at RUBY.setUp(/var/lib/jenkins/plugins/vagrant/WEB-INF/classes/vendor/gems/jruby/1.8/gems/jenkins-plugin-runtime-0.1.26/lib/jenkins/model/environment_proxy.rb:7)
Please help me to solve this issue. Looking forward to your reply.
Thanks
The Jenkins-Vagrant plugin uses a forked version of Vagrant at version 1.0.2.dev.
This version is not compatible with Vagrant's version 2 config format.
If you try with a version 1 Vagrantfile it might work, but that precludes you from using plugins like vagrant-aws.

Resources