背景:我經常最終在不同的操作系統上運行不同的筆記本電腦。這意味着我會浪費大量時間重新安裝相同的程序和應用程序。我決定嘗試使用Vagrant和Ansible自動化。Vagrant-> Ansible:找不到主機文件,提供的主機列表爲空,沒有主機匹配
問題:,因爲我想這個版本是在不同的操作系統我想流浪旋轉起來簡單ubuntu/trusty64
盒部署,並Ansible安裝和執行在Ubuntu中,但我有麻煩Ansible主機。我已經閱讀了Ansible文檔並閱讀了有關庫存的內容,但是沒有清楚地知道這些工作或應該在我的設置中如何定義這些內容。作爲參考,我對Vagrant和Ansible都很陌生,但對VirtualBox有經驗。任何幫助,將不勝感激
Vagrantfile:
# -*- mode: ruby -*-"
# vi: set ft=ruby :
# vagrant plugin install vagrant-ansible-local
VAGRANTFILE_API_VERSION = "2"
$ansible_install_script = <<SCRIPT
if ! which ansible >/dev/null; then
apt-get update -y
apt-get install -y software-properties-common
apt-add-repository -y ppa:ansible/ansible
apt-get update -y
apt-get install -y ansible
fi
SCRIPT
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.define "dev-machine", primary: true do |machine|
machine.vm.box = "ubuntu/trusty64"
machine.vm.hostname = 'local.dev-machine.box'
machine.vm.network :private_network, :ip => '10.20.1.2'
machine.vm.provider "virtualbox" do |vb|
vb.gui = true
vb.memory = "8192"
end # vb
machine.vm.provision "shell", inline: $ansible_install_script
machine.vm.provision "ansibleLocal" do |ansible|
ansible.guest_folder = "/vagrant-ansible"
ansible.raw_arguments = "--inventory=/vagrant-ansbile/ansible_hosts"
ansible.playbook = "playbook.yml"
ansible.limit = "local.dev-machine.box"
end # ansible
end # machine
end # config
playbook.yml:
---
- hosts: all
become: yes
become_method: sudo
tasks:
- name: Check Ubuntu 14.04 running
assert:
that:
- ansible_distribution == 'Ubuntu'
- ansible_distribution_release == 'trusty'
- name: update apt cache
apt: update_cache=yes
- name: install git
apt: name=git-core state=latest
- name: Install Python 3.4
apt: name={{items}} state=latest
with_items:
- python
- python-dev
- python-virtualenv
- python-setuptools
- python-pip
謝謝,我沒有看到語法錯誤。 – jhole89