通过Chef(Kitchen)安装的Vagrant忽略了.kitchen.yml文件中的指定私有IP

时间:2017-12-01 18:37:35

标签: vagrant chef

我将以下信息作为我的.kitchen.yml文件的一部分,我在其中指定了private_network ip。

    - name: dcos-bootstrap
driver:
  network:
    - ["private_network", {ip: "192.168.3.37"}]
run_list: abc::_dcos_bootstrap
driver:
  customize:
    cpus: 1
    memory: 2048
attributes:
  abc:
    defg:
      enable: true
      kube_node: true
includes:
  - centos-7.3

但是当我在我的流浪汉机器上“ip a”时,我得到以下结果,ip为10.0.2.15而不是192.168.3.37 -

    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
   valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
   valid_lft forever preferred_lft forever
    2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 08:00:27:cb:e3:7f brd ff:ff:ff:ff:ff:ff
inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic enp0s3
   valid_lft 86260sec preferred_lft 86260sec
inet6 fe80::df13:cd81:535b:3d27/64 scope link
   valid_lft forever preferred_lft forever
    3: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN
link/ether 02:42:26:d3:6b:62 brd ff:ff:ff:ff:ff:ff
inet 172.17.0.1/16 scope global docker0
   valid_lft forever preferred_lft forever

有人可以帮忙吗?我正在使用Vagrant 2.0.1。

Full kitchen.yml

---
driver:
  name: vagrant
  customize:
  cpus: 1
  memory: 2048

provisioner:
  name: chef_zero
  data_path: test/shared
  require_chef_omnibus: 12.17.44-1

platforms:
  - name: ubuntu-16.04
  - name: centos-7.3

suites:
  - name: dcos-bootstrap
    driver:
       network:
           - ["private_network", {ip: "192.168.3.37"}]
   run_list: abc::_dcos_bootstrap
   driver:
   customize:
       cpus: 1
       memory: 2048
   attributes:
       abc:
           defg:
           enable: true
           kube_node: true
  includes:
       - centos-7.3

1 个答案:

答案 0 :(得分:0)

问题是套件对象下有driver项。它需要看起来像这样:

   suites:
     - name: dcos-bootstrap
       run_list: abc::_dcos_bootstrap
       driver:
         customize:
           cpus: 1
           memory: 2048
         network:
           - ["private_network", {ip: "192.168.3.37"}]
       attributes:
           abc:
               defg:
               enable: true
               kube_node: true
       includes:
           - centos-7.3

否则,driver键的第二个实例会完全覆盖第一个实例,正如您所注意到的那样。