Search code examples
windows-7vagrantchef-infravirtualboxtest-kitchen

Kitchen converge fails with Access Denied when copying password secret


I've been running through the basic chef tutorials and have set up a WinServer2012 vm and successfully deployed my kitchen with the basic awesome customers cookbook using vagrant.

However, I've hit a brick wall when trying to enable security for sql. I've followed the tutorial to create an encrypted sql password file along with the encrypted_data_bag_secret. When running kitchen converge, I get to the 'Transferring files to MACHINE_NAME' stage and then get this access denied error

>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: Failed to complete #converge action: [[WinRM::FS::Core::FileTransporter] Upload failed (exitcode: 1)
sc : Access to the path 'C:\Users\vagrant\AppData\Local\Temp\kitchen' is
denied.
At line:2 char:66
+ function Decode-Base64File($src, $dst) {folder (split-path $dst);sc -force
-Enco ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~
    + CategoryInfo          : NotSpecified: (:) [Set-Content], UnauthorizedAcc
   essException
    + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.Pow
   erShell.Commands.SetContentCommand

]
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration

I have traced the issue to this line in the .kitchen.yml file:

provisioner:
  encrypted_data_bag_secret_key_path: "../../.chef/encrypted_data_bag_secret"

I can see no issue in the vm with permissions, 'C:\Users\vagrant\AppData\Local\Temp\kitchen' exists and is accessible to the vagrant user. It doesn't seem related to the recipes I'm running as I can remove them all and still get the same issue. My colleague with this same setup has the same issue.

Does anyone have any ideas or pointers on what might be going on? I'm on Windows 7, using VirtualBox and vagrant. My Kitchen.yml file is below (although pretty much identical to the tutorial)

    ---
driver:
  name: vagrant
  network:
    - ["private_network", {ip: "192.168.35.35"}]

provisioner:
  name: chef_zero_scheduled_task

platforms:
  - name: windows-2012r2
    driver:
      customize:
        memory: 2048

suites:
  - name: default
    data_bags_path: "../../data_bags"
    run_list:
      - recipe[mock_emr::default]
    provisioner:
      encrypted_data_bag_secret_key_path: "../../.chef/encrypted_data_bag_secret"
    attributes:
      mock_emr:
        secret_file: 'C:/Users/vagrant/AppData/Local/Temp/kitchen/encrypted_data_bag_secret'
      sql_server:
        sysadmins: ['Administrator', 'vagrant']

Solution

  • It is a known bug (https://learn.chef.io/manage-a-web-app/windows/configure-sql-server/)

    Update your test-kitchen to the last version:

    $ chef gem install appbundle-updater
    $ appbundle-updater chefdk test-kitchen v1.7.3
    

    Then Converge again, it should be fixed.