ansible vagrant centos apache

[root@localhost ~]# cat playbook.yml
- hosts: all
# use priviledge (default : root)
  become: yes
# the way to use priviledge
  become_method: sudo
#  remote_user: centos
# define tasks
  tasks:
  - name: httpd is installed
    yum: name=httpd state=installed
  - name: httpd is running and enabled
    service: name=httpd state=started enabled=yes
[root@localhost ~]#


[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 [httpd is installed] ******************************************************
changed: [default]

TASK [httpd is running and enabled] ********************************************
changed: [default]

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

[root@localhost ~]# vagrant ssh
Last login: Tue Sep  3 04:54:56 2019 from 192.168.121.1
[vagrant@localhost ~]$ rpm -qa httpd
httpd-2.4.6-89.el7.centos.1.x86_64
[vagrant@localhost ~]$ 

Comments