From f4f02652f94367966a694b1c5a4f4607ffaa18be Mon Sep 17 00:00:00 2001 From: ger Date: Thu, 12 Apr 2018 21:58:54 +0200 Subject: [PATCH] vagrant ansible provisioning --- vagrant.centos7.ansible | 116 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 vagrant.centos7.ansible diff --git a/vagrant.centos7.ansible b/vagrant.centos7.ansible new file mode 100644 index 0000000..c19e8b3 --- /dev/null +++ b/vagrant.centos7.ansible @@ -0,0 +1,116 @@ +agrant centos7 vm met Ansible als provisioner: + +ger@ger-xiaomi:~$ cd centos_vagrant/ + +ger@ger-xiaomi:~/centos_vagrant$ wget https://github.com/tommy-muehle/puppet-vagrant-boxes/releases/download/1.1.0/centos-7.0-x86_64.box +Saving to: ‘centos-7.0-x86_64.box’ + +centos-7.0-x86_64.box 100%[============================================================================================>] 475,10M 2,87MB/s in 2m 17s + + +ger@ger-xiaomi:~/centos_vagrant$ vagrant box add centos-7.0-x86_64.box --name centos7 +==> box: Box file was not detected as metadata. Adding it directly... +==> box: Adding box 'centos7' (v0) for provider: + box: Unpacking necessary files from: file:///home/ger/centos_vagrant/centos-7.0-x86_64.box +==> box: Successfully added box 'centos7' (v0) for 'virtualbox'! + + config.vm.box = "centos7" + +ger@ger-xiaomi:~/centos_vagrant$ vi Vagrantfile + + config.vm.box = "centos7" + +ger@ger-xiaomi:~/centos_vagrant$ vagrant up +Bringing machine 'default' up with 'virtualbox' provider... +==> default: Importing base box 'centos7'... +==> default: Matching MAC address for NAT networking... +==> default: Setting the name of the VM: centos_vagrant_default_1523562614992_68521 +==> default: Clearing any previously set forwarded ports... +==> default: Clearing any previously set network interfaces... +==> default: Preparing network interfaces based on configuration... + default: Adapter 1: nat +==> default: Forwarding ports... + default: 22 (guest) => 2222 (host) (adapter 1) +==> default: Booting VM... +==> default: Waiting for machine to boot. This may take a few minutes... + default: SSH address: 127.0.0.1:2222 + default: SSH username: vagrant + default: SSH auth method: private key + default: + default: Vagrant insecure key detected. Vagrant will automatically replace + default: this with a newly generated keypair for better security. + default: + default: Inserting generated public key within guest... + default: Removing insecure key from the guest if it's present... + default: Key inserted! Disconnecting and reconnecting using new SSH key... +==> default: Machine booted and ready! +==> 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: 4.3.28 + default: VirtualBox Version: 5.1 +==> default: Mounting shared folders... + default: /vagrant => /home/ger/centos_vagrant + +ger@ger-xiaomi:~/centos_vagrant$ vi Vagrantfile + + config.vm.provision "ansible" do | ansible| + ansible.playbook = "playbook.yml" + ansible.sudo = true + end + + +ger@ger-xiaomi:~/centos_vagrant$ vi playbook.yml + +--- +- hosts: all + tasks: + - yum: pkg=httpd state=installed + +ger@ger-xiaomi:~/centos_vagrant$ vagrant provision +==> default: Running provisioner: ansible... + default: Running ansible-playbook... + ____________ +< PLAY [all] > + ------------ + \ ^__^ + \ (oo)\_______ + (__)\ )\/\ + ||----w | + || || + + ________________________ +< TASK [Gathering Facts] > + ------------------------ + \ ^__^ + \ (oo)\_______ + (__)\ )\/\ + ||----w | + || || + +ok: [default] + ____________ +< TASK [yum] > + ------------ + \ ^__^ + \ (oo)\_______ + (__)\ )\/\ + ||----w | + || || + +changed: [default] + ____________ +< PLAY RECAP > + ------------ + \ ^__^ + \ (oo)\_______ + (__)\ )\/\ + ||----w | + || || + +default : ok=2 changed=1 unreachable=0 failed=0