1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
| ---
- name: Distribute hosts file copy: src: hosts dest: /etc/hosts
- name: Disable selinux selinux: state: disabled
- name: Back up yum Base repo copy: src=/etc/yum.repos.d/CentOS-Base.repo dest=/etc/yum.repos.d/CentOS-Base.repo.backup remote_src=true
- name: Update yum repo get_url: url={{ item.url }} dest={{ item.dest }} with_items: - { url: 'http://mirrors.aliyun.com/repo/Centos-7.repo', dest: '/etc/yum.repos.d/CentOS-Base.repo' } - { url: 'http://mirrors.aliyun.com/repo/epel-7.repo', dest: '/etc/yum.repos.d/epel.repo' }
- name: Distribute yum conf copy: src=yum.conf dest=/etc/yum.conf
- name: Update yum packages yum: name: '*' state: latest
- name: Install essential packages yum: name: ['tree', 'nmap', 'sysstat', 'lrzsz', 'telnet', 'bash-completion', 'bash-completion-extras', 'vim', 'lsof', 'net-tools', 'ntpdate', 'wget'] state: present
- name: Set timezone to Asia/Shanghai timezone: name: Asia/Shanghai
- name: Disable unused services service: name={{ item }} enabled=false state=stopped with_items: - firewalld.service - postfix.service - NetworkManager.service
- name: Cron for sync time cron: name: sync time hour: '*/1' job: "/usr/sbin/ntpdate ntp.aliyun.com &> /dev/null" state: present
- name: Configure SSH lineinfile: path=/etc/ssh/sshd_config regexp={{ item.regexp }} line={{ item.line }} with_items: - { regexp: '^PermitRootLogin', line: 'PermitRootLogin yes' } - { regexp: '^PasswordAuthentication', line: 'PasswordAuthentication yes' } - { regexp: '^UseDNS', line: 'UseDNS no' } - { regexp: '^GSSAPIAuthentication', line: 'GSSAPIAuthentication no' } - { regexp: '^PermitEmptyPasswords', line: 'PermitEmptyPasswords no' } notify: restart sshd
|