Last active
August 26, 2020 03:20
-
-
Save lihongjie0209/6d71778d375daac9380ec5a80fed5ff2 to your computer and use it in GitHub Desktop.
初始化服务器的ansible脚本
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: all | |
tasks: | |
- name: Set timezone to Asia/Shanghai | |
timezone: | |
name: Asia/Shanghai | |
- name: disable selinux | |
selinux: | |
state: disabled | |
- name: disable firewalld | |
service: | |
name: firewalld | |
state: stopped | |
enabled: no | |
- name: add aliyun base repo | |
get_url: | |
url: https://mirrors.aliyun.com/repo/Centos-7.repo | |
dest: /etc/yum.repos.d/CentOS-Base.repo | |
force: yes | |
- name: add aliyun epel repo | |
yum_repository: | |
name: epel | |
description: EPEL YUM repo | |
file: epel | |
baseurl: https://mirrors.aliyun.com/epel/$releasever/$basearch/ | |
gpgcheck: no | |
- name: add aliyun ius repo | |
yum_repository: | |
name: ius | |
description: ius YUM repo | |
file: ius | |
baseurl: https://mirrors.aliyun.com/ius/7/$basearch/ | |
gpgcheck: no | |
- name: add aliyun docker repo | |
yum_repository: | |
name: docker-ce | |
description: docker repo | |
file: docker-ce | |
baseurl: https://mirrors.aliyun.com/docker-ce/linux/centos/7/$basearch/stable | |
gpgcheck: no | |
- name: add aliyun k8s repo | |
yum_repository: | |
name: kubernetes | |
description: kubernetes repo | |
file: kubernetes | |
baseurl: https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/ | |
gpgcheck: no | |
- name: add tuna mysql repo | |
yum_repository: | |
name: mysql | |
description: mysql repo | |
file: mysql | |
baseurl: https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-5.7-community-el7-x86_64/ | |
gpgcheck: no | |
- name: add tuna elk7 repo | |
yum_repository: | |
name: elk7 | |
description: elk7 repo | |
file: elk7 | |
baseurl: https://mirrors.tuna.tsinghua.edu.cn/elasticstack/yum/elastic-7.x/ | |
gpgcheck: no | |
- name: add tuna elk6 repo | |
yum_repository: | |
name: elk6 | |
description: elk6 repo | |
file: elk6 | |
baseurl: https://mirrors.tuna.tsinghua.edu.cn/elasticstack/yum/elastic-6.x/ | |
gpgcheck: no | |
- name: install packages | |
yum: | |
name: | |
- nfs-utils | |
- net-tools | |
- the_silver_searcher | |
- nmon | |
- rsync | |
- dstat | |
- ncdu | |
- lsof | |
- tmux | |
- htop | |
- lrzsz | |
- vim | |
- wget | |
- curl | |
- zip | |
- unzip | |
- curl | |
- chrony | |
- tree | |
- iotop | |
- sl | |
- telnet | |
- nmap | |
- nc | |
- psmisc | |
- dos2unix | |
- sysstat | |
- bash-completion | |
- bash-completion-extras | |
- yum-cron | |
state: present | |
update_cache: yes | |
- name: install vmware tools | |
yum: | |
name: open-vm-tools | |
state: present | |
when: ansible_virtualization_type == "VMware" | |
- name: enable and start chronyd | |
service: | |
name: chronyd | |
state: started | |
enabled: yes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
使用方法