[root@localhost ~]# cat playbook.yml
- hosts: all
user: root
become: yes
# the way to use priviledge
become_method: sudo
tasks:
- name: install httpd
yum:
name: httpd
- name: install php
yum: name={{item}} state=installed
with_items:
- php
- php-mysql
- php-pdo
- php-gd
- php-mbstring
- name: copy file
shell: echo "<?php phpinfo (); ?>" > /var/www/html/info.php
- name: install mariadb
yum: name={{item}} state=installed
with_items:
- mariadb-server
- mariadb
- name: restart httpd
service:
name: httpd
state: restarted
[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 [install httpd] ***********************************************************
changed: [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: ['php', 'php-mysql', 'php-
pdo', 'php-gd', 'php-mbstring']` 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'php', u'php-mysql', u'php-pdo', u'php-gd', u'php-mbstring'])
TASK [copy file] ***************************************************************
changed: [default]
TASK [install mariadb] *********************************************************
[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: ['mariadb-server',
'mariadb']` 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'mariadb-server', u'mariadb'])
TASK [restart httpd] ***********************************************************
changed: [default]
PLAY RECAP *********************************************************************
default : ok=6 changed=5 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
- hosts: all
user: root
become: yes
# the way to use priviledge
become_method: sudo
tasks:
- name: install httpd
yum:
name: httpd
- name: install php
yum: name={{item}} state=installed
with_items:
- php
- php-mysql
- php-pdo
- php-gd
- php-mbstring
- name: copy file
shell: echo "<?php phpinfo (); ?>" > /var/www/html/info.php
- name: install mariadb
yum: name={{item}} state=installed
with_items:
- mariadb-server
- mariadb
- name: restart httpd
service:
name: httpd
state: restarted
[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 [install httpd] ***********************************************************
changed: [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: ['php', 'php-mysql', 'php-
pdo', 'php-gd', 'php-mbstring']` 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'php', u'php-mysql', u'php-pdo', u'php-gd', u'php-mbstring'])
TASK [copy file] ***************************************************************
changed: [default]
TASK [install mariadb] *********************************************************
[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: ['mariadb-server',
'mariadb']` 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'mariadb-server', u'mariadb'])
TASK [restart httpd] ***********************************************************
changed: [default]
PLAY RECAP *********************************************************************
default : ok=6 changed=5 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
Comments
Post a Comment