---
- hosts: all
sudo: yes
tasks:
- name: add a new user
user: name=admin password=password&2016!
- hosts: unix
sudo: yes
tasks:
- name: disable selinux
selinux: state=disabled
when: ansible_os_family == 'RedHat'
- name: stop firewalld
service: name=firewalld state=stopped
when: ansible_os_family == 'RedHat'
- name: disable firewalld
command: systemctl disable firewalld
when: ansible_os_family == 'RedHat'
- name: install adminpackages
yum: name={{item}} state=latest
with_items:
- mlocate
- iputils
- bind-utils
when: ansible_os_family == 'RedHat'
- hosts: http_servers
sudo: yes
tasks:
- name: install apache
yum: name=httpd state=latest
- name: start apache and enabled
service: name=httpd state=started enabled=yes
- name: exec shell commands
command: echo "hello ansible" > /root/hello.txt
- name: copy index.html
copy: src=./files/index.html dest=/var/www/html/index.html
- name: install php packages
yum: name={{item}} state=latest
with_items:
- php
- php-devel
- php-mbstring
- php-pgsql
notify:
- restart httpd
- name: copy hello.php
copy: src=./files/hello.php dest=/var/www/html/hello.php
handlers:
- name: restart httpd
service: name=httpd state=restarted
- hosts: tomcat_servers
sudo: yes
tasks:
- name: install tomcat and java
yum: name={{item}} state=latest
with_items:
- java-1.8.0-openjdk
- java-1.8.0-openjdk-devel
- tomcat
- tomcat-webapps
- tomcat-admin-webapps
- name: start tomcat and enabled
service: name=tomcat state=started enabled=yes
- hosts: postgres
sudo: yes
tasks:
- name: install PostgreSQL
yum: name={{item}} state=latest
with_items:
- postgresql-server
- postgresql-devel
- postgresql-contrib
- postgresql
- name: checking directory
stat: path=/var/lib/pgsql/data
register: pgdata
- name: postgresql initdb
become: True
command: service postgresql initdb
when: not pgdata.stat.exists
- name: start postgresql and enabled
service: name=postgresql state=started enabled=yes
|