kitchen-salt icon indicating copy to clipboard operation
kitchen-salt copied to clipboard

FreeBSD setup don't work

Open ymasson opened this issue 6 years ago • 1 comments

I'm trying to run tests on FreeBSD 11 Openstack instance.

driver:
  name: openstack
[.......]
platforms:
  - name: freebsd11
    driver:
      image_ref: "FreeBSD 11"
root@3ea0ef1d6567:/tmp/role-to-test# kitchen verify default-freebsd11
-----> Starting Kitchen (v1.23.2)
-----> Creating <default-freebsd11>...
       OpenStack instance with ID of <1e02a2b2-8619-4def-8b86-bec047833217> is ready.
       Waiting for network information to be available...
       Waiting for server to be ready...
       Waiting for SSH service on X.X.X.X:22, retrying in 3 seconds
       Waiting for SSH service on X.X.X.X:22, retrying in 3 seconds
       Waiting for SSH service on X.X.X.X:22, retrying in 3 seconds
       [SSH] Established
       Adding OpenStack hint for ohai
       sudo: bash: command not found
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: 1 actions failed.
>>>>>>     Failed to complete #create action: [SSH exited (1) for command: [sudo mkdir -p /etc/chef/ohai/hints && sudo bash -c 'echo {} > /etc/chef/ohai/hints/openstack.json']] on default-freebsd11
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration

Add packages :

driver:
  name: openstack
[.......]
platforms:
  - name: freebsd11
    driver:
      image_ref: "FreeBSD 11"
      user_data: /opt/kitchen/freebsd-setup.sh

freebsd-setup.sh script :

#!/bin/sh
pkg install -y bash sudo
root@3ea0ef1d6567:/tmp/role-to-test# kitchen verify default-freebsd11
-----> Starting Kitchen (v1.23.2)
-----> Creating <default-freebsd11>...
       OpenStack instance with ID of <c18a67dc-d54e-4d1d-b9da-a66d7a9cfa06> is ready.
       Waiting for network information to be available...
       Waiting for server to be ready...
       Waiting for SSH service on X.X.X.X:22, retrying in 3 seconds
       Waiting for SSH service on X.X.X.X:22, retrying in 3 seconds
       Waiting for SSH service on X.X.X.X:22, retrying in 3 seconds
       [SSH] Established
       Adding OpenStack hint for ohai
       Finished creating <default-freebsd11> (1m29.36s).
-----> Converging <default-freebsd11>...
       Preparing files for transfer
       Preparing salt-minion
       Preparing pillars into /srv/pillar
       Preparing state collection
       neither collection_name or formula have been set, assuming this is a pre-built collection
       Preparing state_top
       Preparing scripts into /etc/salt/scripts
       Unmatched '''.
       #: Command not found.
       Badly placed ()'s.
       Ambiguous output redirect.
       then: Command not found.
       return: Command not found.
       else: endif not found.
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: 1 actions failed.
>>>>>>     Converge failed on instance <default-freebsd11>.  Please see .kitchen/logs/default-freebsd11.log for more details
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration

The kitchen logs contain this script https://github.com/saltstack/kitchen-salt/blob/master/lib/kitchen/provisioner/install.erb

E, [2018-09-18T12:41:59.513179 #870] ERROR -- default-freebsd11: /var/lib/gems/2.3.0/gems/test-kitchen-1.23.2/lib/kitchen/command.rb:169:in `block (2 levels) in run_action'
E, [2018-09-18T12:41:59.513196 #870] ERROR -- default-freebsd11: ----End Backtrace-----
E, [2018-09-18T12:41:59.513207 #870] ERROR -- default-freebsd11: ---Nested Exception---
E, [2018-09-18T12:41:59.513218 #870] ERROR -- default-freebsd11: Class: Kitchen::Transport::SshFailed
E, [2018-09-18T12:41:59.513228 #870] ERROR -- default-freebsd11: Message: SSH exited (1) for command: [sh -c '
# Check whether a command exists - returns 0 if it does, 1 if it does not
exists() {
  if command -v $1 >/dev/null 2>&1
  then
    return 0
  else
    return 1
  fi
}

[...........]

else
  echo "You asked for latest and you have got ${SALT_VERSION} installed, dunno how to fix that, sorry!"
  exit 2
fi

'

]
E, [2018-09-18T12:41:59.513471 #870] ERROR -- default-freebsd11: ----------------------
E, [2018-09-18T12:41:59.513500 #870] ERROR -- default-freebsd11: ------Backtrace-------
root@3ea0ef1d6567:/tmp/role-to-test# kitchen diagnose default-freebsd11
---
timestamp: 2018-09-18 12:44:45 UTC
kitchen_version: 1.23.2
instances:
  default-freebsd11:
    platform:
      os_type: unix
      shell_type: bourne
    state_file:
      hostname: X.X.X.X
      last_action: create
      last_error: Kitchen::ActionFailed
      server_id: d4c6a4e1-9d64-450d-ae19-a29e687aefde
    driver:
      allocate_floating_ip: false
      availability_zone: 
      block_device_mapping: 
      connect_timeout: 180
      flavor_ref: small
      floating_ip: 
      floating_ip_pool: 
      glance_cache_wait_timeout: 600
      image_ref: FreeBSD 11
      key_name: kitchen-test
      kitchen_root: "/tmp/role-to-test"
      log_level: :info
      metadata: 
      name: openstack
      network_id: 
      network_ref: 
      no_ssh_tcp_check: false
      no_ssh_tcp_check_sleep: 120
      openstack_api_key: XXXXXXX
      openstack_auth_url: https://XXXXXXX/
      openstack_domain_id: default
      openstack_network_name: 
      openstack_project_id: XXXXXXX
      openstack_project_name: 
      openstack_region: XXXXXXX
      openstack_service_name: 
      openstack_username: XXXXXXX
      port: '22'
      pre_create_command: 
      private_ip_order: 0
      public_ip_order: 0
      read_timeout: 180
      security_groups:
      - default
      server_name: 
      server_name_prefix: kitchen
      test_base_path: "/tmp/role-to-test/test/integration"
      use_ipv6: false
      user_data: "/opt/kitchen/freebsd-setup.sh"
      write_timeout: 180
    provisioner:
      bootstrap_url: https://raw.githubusercontent.com/saltstack/kitchen-salt/master/assets/install.sh
      cache_commands: []
      chef_bootstrap_url: https://www.chef.io/chef/install.sh
      command_prefix: 
      debug: 
      dependencies: []
      downloads: {}
      dry_run: false
      ftp_proxy: 
      http_proxy: 
      https_proxy: 
      init_environment: |
        # deal with Docker
        sudo mkdir /var/run/sshd || /bin/true
      install_after_init_environment: false
      is_file_root: true
      kitchen_root: "/tmp/role-to-test"
      local_salt_root: 
      max_retries: 1
      name: salt_solo
      omnibus_cachier: false
      pillars_from_directories: []
      pip_bin: pip
      pip_editable: false
      pip_extra_index_url: []
      pip_index_url: https://pypi.python.org/simple/
      pip_pkg: salt==%s
      remote_states: 
      require_chef: false
      require_chef_omnibus: false
      retry_on_exit_code: []
      root_path: "/tmp/kitchen"
      salt_apt_repo: https://repo.saltstack.com/apt/ubuntu/16.04/amd64/
      salt_apt_repo_key: https://repo.saltstack.com/apt/ubuntu/16.04/amd64/latest/SALTSTACK-GPG-KEY.pub
      salt_bootstrap_options: ''
      salt_bootstrap_url: https://bootstrap.saltstack.com
      salt_config: "/etc/salt"
      salt_copy_filter: []
      salt_env: base
      salt_file_root: "/srv/salt"
      salt_force_color: true
      salt_install: bootstrap
      salt_minion_config: "/etc/salt/minion"
      salt_minion_config_dropin_files: []
      salt_minion_config_template: 
      salt_minion_extra_config: {}
      salt_minion_id: 
      salt_pillar_root: "/srv/pillar"
      salt_ppa: ppa:saltstack/salt
      salt_spm_root: "/srv/spm"
      salt_state_top: "/srv/salt/top.sls"
      salt_version: latest
      salt_yum_repo: https://repo.saltstack.com/yum/redhat/$releasever/$basearch/archive/%s
      salt_yum_repo_key: https://repo.saltstack.com/yum/redhat/$releasever/$basearch/archive/%s/SALTSTACK-GPG-KEY.pub
      salt_yum_repo_latest: https://repo.saltstack.com/yum/redhat/salt-repo-latest-2.el7.noarch.rpm
      salt_yum_rpm_key: https://repo.saltstack.com/yum/redhat/7/x86_64/archive/%s/SALTSTACK-GPG-KEY.pub
      state_collection: false
      state_top:
        base:
          "*":
          - ssh
      state_top_from_file: false
      sudo: true
      sudo_command: sudo -E
      test_base_path: "/tmp/role-to-test/test/integration"
      vendor_path: 
      vendor_repo: {}
      wait_for_retry: 30
    transport:
      compression: false
      compression_level: 0
      connection_retries: 5
      connection_retry_sleep: 1
      connection_timeout: 15
      keepalive: true
      keepalive_interval: 60
      kitchen_root: "/tmp/role-to-test"
      log_level: :info
      max_ssh_sessions: 9
      max_wait_until_ready: 600
      name: ssh
      port: 22
      ssh_gateway: 
      ssh_gateway_port: 22
      ssh_gateway_username: 
      ssh_http_proxy: 
      ssh_http_proxy_password: 
      ssh_http_proxy_port: 
      ssh_http_proxy_user: 
      ssh_key: "/root/.ssh/id_rsa"
      test_base_path: "/tmp/role-to-test/test/integration"
      username: freebsd
    verifier:
      chef_omnibus_root: "/opt/chef"
      command: py.test -v --color=yes --host="ssh://${KITCHEN_USERNAME}@${KITCHEN_HOSTNAME}?ssh_identity_file=${KITCHEN_SSH_KEY}"
        --junit-xml "junit-${KITCHEN_INSTANCE}.xml" test/integration/${KITCHEN_SUITE}*
      command_prefix: 
      debug: 
      ftp_proxy: 
      http_proxy: 
      https_proxy: 
      kitchen_root: "/tmp/role-to-test"
      live_stream: !ruby/object:IO {}
      log_level: :info
      name: shell
      remote_exec: false
      root_path: "/tmp/verifier"
      shellout_opts: {}
      sleep: 0
      sudo: true
      sudo_command: sudo -E
      suite_name: default
      test_base_path: "/tmp/role-to-test/test/integration"

The default FreeBSD shell is csh. If I add chsh -s /usr/local/bin/bash in freebsd-setup.sh , same error.

If I add install_after_init_environment parameter like this

driver:
  name: openstack
[.......]
platforms:
  - name: freebsd11
    driver:
      image_ref: "FreeBSD 11"
    provisioner:
      install_after_init_environment: True

It's stuck and need to be killed

       [SSH] Established
       Adding OpenStack hint for ohai
       Finished creating <default-freebsd11> (2m14.90s).
-----> Converging <default-freebsd11>...
       Preparing files for transfer
       Preparing salt-minion
       Preparing pillars into /srv/pillar
       Preparing state collection
       neither collection_name or formula have been set, assuming this is a pre-built collection
       Preparing state_top
       Preparing scripts into /etc/salt/scripts
       #: Command not found.
       Transferring files to <default-freebsd11>
^Croot@3ea0ef1d6567:/tmp/role-to-test#

chsh -s /usr/local/bin/bash and install_after_init_environment together, also stuck

My kitchen Gemfile used with Debian 9 Docker image (like https://gitlab.com/ymasson-salt/ci-kitchen/blob/devel/Dockerfile) :

source "http://rubygems.org"

gem 'test-kitchen'
gem 'kitchen-docker'
gem 'kitchen-salt'
gem "kitchen-openstack"

### ohai <14.0.28 for Ruby <=2.3
gem 'ohai', '<14.0.28'

Thanks for your help Yann

ymasson avatar Sep 18 '18 13:09 ymasson

I have no idea why this would be broken in FreeBSD, and I do not have the bandwidth to figure it out and fix it, so a PR fixing this for freebsd would be greatly appreciated.

Thanks, Daniel

gtmanfred avatar Mar 01 '19 21:03 gtmanfred