Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - hosts: testservers
- tasks:
- #### System Update ####
- ## CentOS ##
- - name: System Update CentOS
- yum: name=* state=latest
- when: ansible_distribution == "CentOS"
- - name: Disable SELinux
- selinux: state=disabled
- when: ansible_distribution == "CentOS"
- ## SUSE ##
- - name: System Update SUSE
- zypper: name=* state=latest
- when: ansible_os_family == "Suse"
- - name: Apply ALL patches SUSE
- zypper: name=* state=latest type=patch
- when: ansible_os_family == "Suse"
- ## ALL OS ##
- - name: Reboot server
- shell: sleep 3 && /sbin/shutdown -r now "Ansible system reboot"
- async: 1 #ansible-playbook this_file.yml --check не отработает! закомментить при тесте!#
- poll: 0
- - name: Wait for hosts sshd
- local_action: wait_for host={{ inventory_hostname }} port=22 delay=20 connect_timeout=200
- become: false
- delegate_to: localhost
- #### Software installation ####
- ## Apache CentOS ##
- - name: Install Apache CentOS
- yum: pkg=httpd state=latest
- when: ansible_distribution == "CentOS"
- - name: Enable Apache on System Boot CentOS
- service: name=httpd enabled=yes
- when: ansible_distribution == "CentOS"
- - name: Starting service Apache CentOS
- service: name=httpd state=started
- when: ansible_distribution == "CentOS"
- ## Apache SUSE ##
- - name: Install Apache SUSE
- zypper: name=apache2 state=latest
- when: ansible_os_family == "Suse"
- - name: Enable Apache on System Boot SUSE
- service: name=apache2 enabled=yes
- when: ansible_os_family == "Suse"
- #### Firewall config ####
- ## CentOS ##
- - name: Allow HTTP CentOS
- command: firewall-cmd --add-service=http --permanent
- when: ansible_distribution == "CentOS"
- - name: Allow HTTPs CentOS
- command: firewall-cmd --add-service=https --permanent
- when: ansible_distribution == "CentOS"
- ## SUSE ##
- - name: Allow SSH SUSE
- command: iptables -A INPUT -p tcp --dport 22 -j ACCEPT
- when: ansible_os_family == "Suse"
- - name: Allow HTTP SUSE
- command: iptables -A INPUT -p tcp --dport 80 -j ACCEPT
- when: ansible_os_family == "Suse"
- - name: Allow HTTPs SUSE
- command: iptables -A INPUT -p tcp --dport 443 -j ACCEPT
- when: ansible_os_family == "Suse"
- #### Firewall reboot ####
- - name: Reload Firewall settings CentOS
- command: firewall-cmd --reload
- when: ansible_distribution == "CentOS"
- # - name: Reload Firewall settings SUSE
- # command: /etc/init.d/SuSEfirewall2_init restart
- # when: ansible_os_family == "Suse"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement