背景:別のオペレーティングシステムで動作する別のラップトップで作業することがよくあります。つまり、同じプログラムやアプリケーションを再インストールするのに多くの時間を費やすことになります。私はVagrantとAnsibleを使ってこれを自動化しようと決めました。Vagrant-> Ansible:ホストファイルが見つからない、ホストリストが空で、ホストが一致しない場合
問題:しかし私は、私がいる、このビルドは、私はベイグラントをインストールする簡単なubuntu/trusty64
ボックス、およびAnsibleをスピンアップし、Ubuntuのボックス上で実行するオペレーティング・システムの範囲に展開可能になりたいと危険なホストとのトラブル。私は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