2017-10-21 1 views
0

私はVagrantでubuntu/xenial64 vmを作成し、それをAnsibleを使用してプロビジョニングしようとしています。ツールのインストールされたバージョンは次のとおりです。VagrantとAnsibleを使用してubuntu/xenial64を提供する

ベイグラント:2.0.0
Ansible:2.3.2.0
のPython:2.7.10
Virtualboxの:5.1.30

これらは、私が走っているディレクトリの内容vagrant up

├── Vagrantfile 
└── playbooks 
    ├── inventory 
    ├── main.yml 
    └── vars.yml 

これらはVagrantfileの内容は次のとおり

# -*- mode: ruby -*- 
# vi: set ft=ruby : 

Vagrant.configure(2) do |config| 
    config.vm.box = "ubuntu/xenial64" 
    config.ssh.insert_key = true 

    config.vm.provider "virtualbox" do |v| 
    v.name = "ubuntu" 
    v.memory = 1024 
    v.cpus = 2 
    end 

    config.vm.hostname = "ubuntu" 
    config.vm.network :private_network, ip: "192.168.33.7" 

    config.vm.provision "ansible" do |ansible| 
    ansible.playbook = "playbooks/main.yml" 
    ansible.sudo = true 
    ansible.verbose = true 
    ansible.inventory_path = "playbooks/inventory" 
    ansible.compatibility_mode = "2.0" 
    end 

end 
playbooks/main.yml

--- 
- hosts: ubuntu 
    become: yes 

    vars_files: 
    - vars.yml 

    roles: 
    - geerlingguy.docker 

playbooks/inventory

[ubuntu] 
192.168.33.7 

[ubuntu:vars] 
ansible_ssh_user=vagrant 
ansible_ssh_private_key_file=~/.vagrant.d/insecure_private_key 

プレイブック/ vars.yml:

docker_edition: 'ce' 
docker_package: "docker-{{ docker_edition }}" 
docker_package_state: present 

私はvagrant upを実行すると、出力は次のようになります。しかし

==> default: Checking for guest additions in VM... 
    default: The guest additions on this VM do not match the installed version of 
    default: VirtualBox! In most cases this is fine, but in rare cases it can 
    default: prevent things such as shared folders from working properly. If you see 
    default: shared folder errors, please make sure the guest additions within the 
    default: virtual machine match the version of VirtualBox you have installed on 
    default: your host and reload your VM. 
    default: 
    default: Guest Additions Version: 5.0.40 
    default: VirtualBox Version: 5.1 
==> default: Setting hostname... 
==> default: Configuring and enabling network interfaces... 
==> default: Mounting shared folders... 
    default: /vagrant => /Users/danilo/tutorials/ansible ubuntu 
==> default: Running provisioner: ansible... 
    default: Running ansible-playbook... 
PYTHONUNBUFFERED=1 ANSIBLE_FORCE_COLOR=true ANSIBLE_HOST_KEY_CHECKING=false ANSIBLE_SSH_ARGS='-o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -o IdentityFile=/Users/danilo/tutorials/ansible ubuntu/.vagrant/machines/default/virtualbox/private_key -o ControlMaster=auto -o ControlPersist=60s' ansible-playbook --connection=ssh --timeout=30 --extra-vars=ansible_user\=\'ubuntu\' --limit="default" --inventory-file=playbooks/inventory --become -v playbooks/main.yml 
No config file found; using defaults 
ERROR! Specified --limit does not match any hosts 
Ansible failed to complete successfully. Any error output should be 
visible above. Please fix these errors and try again. 

、予想通りvagrant ssh作品。私は何が欠けているかもしれない何かアイデア?それ以外の場合は劇中でhosts: defaultに変更

config.vm.define "ubuntu" do |ubuntu| 
    ubuntu.vm.provision "ansible" do |ansible| 
    ansible.playbook = "playbooks/main.yml" 
    ansible.sudo = true 
    ansible.verbose = true 
    ansible.inventory_path = "playbooks/inventory" 
    ansible.compatibility_mode = "2.0" 
    end 
end 

:あなたはhosts: ubuntuを使用する場合

答えて

1

まず、あなたは、マシンの名前を定義する必要があります。

しかし、その後...

  • あなたは192.168.33.7を経由して提供しようと、なぜ私は考えている - それは、このユースケースのために完全に不要と思われる - あなたは同じインベントリにVagrantfile
  • からansible.inventory_pathを削除することができますあなたのファイル
  • ansible.sudoはAを実行しているVagrantfile
  • にも必要ありませんubuntu/xenial64ボックスに設定されていないユーザーvagrantを指定しますubuntu/xenial64途中でnsibleこの方法は、おそらくこれらの変更を行って、もう一度実行した後のPython 2
+0

の不足のために失敗します、私は[192.168.33.7] PLAY」を取得************* ********************************************** スキップ:ホストが一致しません " –

+0

もっとお試しください。 – techraf

関連する問題