ansible vagrant centos tomcat

Vagrantfile

Vagrant.configure("2") do |config|
config.vm.box = "generic/centos7"
config.vm.provision "ansible" do |ansible|
    ansible.playbook = "playbook.yml"
    ansible.playbook = "php.yml"
    ansible.playbook = "tomcat.yml"
  end


tomcat.yml
  - hosts: all
  user: root
  become: yes
# the way to use priviledge
  become_method: sudo
  tasks:
    - name: install php
      yum: name={{item}} state=installed
      with_items:
      - tomcat
      - tomcat-webapps
      - tomcat-admin-webapps
      - tomcat-docs-webapp

root@localhost ~]# vagrant provision
==> default: Running provisioner: ansible...
Vagrant has automatically selected the compatibility mode '2.0'
according to the Ansible version installed (2.8.4).

Alternatively, the compatibility mode can be specified in your Vagrantfile:
https://www.vagrantup.com/docs/provisioning/ansible_common.html#compatibility_mode

    default: Running ansible-playbook...

PLAY [all] *********************************************************************

TASK [Gathering Facts] *********************************************************
ok: [default]

TASK [install php] *************************************************************
[DEPRECATION WARNING]: Invoking "yum" only once while using a loop via
squash_actions is deprecated. Instead of using a loop to supply multiple items
and specifying `name: "{{item}}"`, please use `name: ['tomcat', 'tomcat-
webapps', 'tomcat-admin-webapps', 'tomcat-docs-webapp']` and remove the loop.
This feature will be removed in version 2.11. Deprecation warnings can be
disabled by setting deprecation_warnings=False in ansible.cfg.
changed: [default] => (item=[u'tomcat', u'tomcat-webapps', u'tomcat-admin-webapps', u'tomcat-docs-webapp'])

PLAY RECAP *********************************************************************
default                    : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0 

[root@localhost ~]#


[root@localhost ~]# vagrant ssh
Last login: Tue Sep  3 05:26:34 2019 from 192.168.121.1

[vagrant@localhost ~]$ rpm -aq tomcat*
tomcat-el-2.2-api-7.0.76-9.el7_6.noarch
tomcat-7.0.76-9.el7_6.noarch
tomcat-jsp-2.2-api-7.0.76-9.el7_6.noarch
tomcat-lib-7.0.76-9.el7_6.noarch
tomcat-docs-webapp-7.0.76-9.el7_6.noarch
tomcat-admin-webapps-7.0.76-9.el7_6.noarch
tomcat-servlet-3.0-api-7.0.76-9.el7_6.noarch
tomcat-webapps-7.0.76-9.el7_6.noarch
[vagrant@localhost ~]$ 

Comments