赞
踩
目录
| ansible | 10.0.0.10 |
| lb-server | 10.0.0.11 |
| web01 | 10.0.0.15 |
| web02 | 10.0.0.16 |
| redis | 10.0.0.20 |
- [root@ansible ~]# mkdir -p ansible/roles/
- [root@ansible ~]# cd ansible/roles/
- [root@ansible roles]# mkdir -p {nginx,php-fpm,redis}/{tasks,templates,handlers,file
-
- [root@ansible roles]# mkdir -p basic/{tasks,templates,handlers,files}
- [root@ansible roles]# mkdir group_vars
-
-
- [root@ansible roles]# egrep "^[a-Z]" ansible.cfg
- inventory = ./hosts
- forks = 5
-
- [root@ansible roles]# grep "^[^#]" hosts
- [lb-server]
- 10.0.0.11
- [webserver]
- 10.0.0.15
- 10.0.0.16
- [redis]
- 10.0.0.20

- [root@ansible roles]# cat basic/tasks/main.yml
- - name: Install Nginx Repo
- yum_repository:
- name: ansible_nginx
- description: ansible_nginx_repo
- baseurl: http://nginx.org/packages/centos/$releasever/$basearch/
- gpgcheck: no
- gpgkey: https://nginx.org/keys/nginx_signing.key
- when: ( ansible_hostname is match ("web*") or ansible_hostname is match ("lb*") )
-
- - name: PHP Reop
- yum_repository:
- name: ansible_php
- description: ansible_php_repo
- baseurl: http://us-east.repo.webtatic.com/yum/el7/x86_64/
- gpgcheck: no
- when: ( ansible_hostname is match ("web*") )
-
- - name: epel
- yum:
- name: epel-release.noarch
- state: present
-
- - name: Install Basices
- yum:
- name: "{
- { item }}"
- state: present
- loop:
- - vim
- - wget
- - make
- - automake
- - lrzsz
- - tree
- - net-tools
- - nfs-utils
- - rsync
- - ntpdate
- - unzip
- - zip
-
- - name: Disabled Firewall
- systemd:
- name: firewalld
- state: stopped
- enabled: no
-
- - name: Disabled Selinux
- selinux:
- state: disabled
-
- - name: Create Group
- group:
- name: "{
- { group }}"
- gid: "{
- { id }}"
-
- - name: Create User
- user:
- name: "{
- { user }}"
- uid: "{
- { id }}"
- group: "{
-

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。