Signed-off-by: Wang Chenglong 18509160991@163.com --- lib/handle_ansible.sh | 89 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 lib/handle_ansible.sh
diff --git a/lib/handle_ansible.sh b/lib/handle_ansible.sh new file mode 100644 index 000000000..415abfba0 --- /dev/null +++ b/lib/handle_ansible.sh @@ -0,0 +1,89 @@ +#!/bin/bash + +epelrpm() +{ + sed -i "s/epel-release/bash/g" /root/.ansible/roles/*/tasks/*.yml +} + +include_vars() +{ + sed -i 's/{{ ansible_distribution_major_version }}/7/g' /root/.ansible/roles/*/tasks/*.yml + sed -i 's/{{ansible_distribution_major_version}}/7/g' /root/.ansible/roles/*/tasks/*.yml + sed -i 's/{{ ansible_distribution }}/CentOS/g' /root/.ansible/roles/*/tasks/*.yml + sed -i 's/{{ os_family | lower }}.yml/rhel.yml/g' /root/.ansible/roles/*/tasks/*.yml + sed -i 's/{{ ansible_distribution_file_variety }}/RedHat/g' /root/.ansible/roles/*/tasks/*.yml + sed -i 's/{{ os_name }}/redhat/g' /root/.ansible/roles/*/tasks/*.yml + sed -i 's/{{ os_release }}/rhel7/g' /root/.ansible/roles/*/tasks/*.yml + + grep with_first_found /root/.ansible/roles/*/tasks/*.yml + [ "$?" == "0" ] && { + sed -i '/with_first_found:/a\ - redhat-7.yml' /root/.ansible/roles/*/tasks/*.yml + } + + [ -d /root/.ansible/roles/*/vars/ansible_distribution ] && { + cp /root/.ansible/roles/*/vars/ansible_distribution/redhat.yml /root/.ansible/roles/*/vars/ansible_distribution/openeuler.yml + sed -i 's/centos/rhel' /root/.ansible/roles/*/vars/ansible_distribution/openeuler.yml + } + + cd /root/.ansible/roles/*/ + cp ./vars/RedHat-7.yml ./vars/RedHat-20.yml + cp ./vars/CentOS-7.yml ./vars/CentOS-20.yml + + cp ./vars/CentOS.yml ./vars/openEuler.yml + sed -i 's/"7"/"20"/g' ./vars/openEuler.yml + + cp vars/ansible_distribution/redhat.yml vars/ansible_distribution/openeuler.yml + cp vars/ansible_os_family/redhat.yml vars/ansible_os_family/openeuler.yml + + # GPG signature + grep 'state: present' ./tasks/install.yml + [ "$?" == "0" ] && { + sed -i '/yum:/a\ disable_gpg_check: yes' ./tasks/install.yml + } +} + +service_firewall() +{ + systemctl enable firewall +} + +service_redis() +{ + useradd redis -s /usr/sbin/nologin + mkdir -p /var/log/redis + chown -R redis:root /var/log/redis + mkdir -p /var/lib/redis + chown -R redis:root /var/lib/redis +} + +service_postgresql() +{ + sed -i 's/^replication_timeout/#replication_timeout/g' templates/postgresql.conf.j2 + sed -i 's/^checkpoint_segments/#checkpoint_segments/g' templates/postgresql.conf.j2 + sed -i 's/^sql_inheritance/#sql_inheritance/g' templates/postgresql.conf.j2 +} + +service_nfs() +{ + systemctl unmask network.target +} + +command_python() +{ + sed -i 's/3.6.5/3.7.5/g' /root/.ansible/roles/*/defaults/* + +} + + + + +handle_ansible() +{ + epelrpm + include_vars + service_firewall + service_redis + service_postgresql + service_nfs + command_python +}