From ab84a6b1e7c0d8e126c41c6b9bdbd8b703d4baab Mon Sep 17 00:00:00 2001 From: Pavel Muhortov Date: Sun, 24 Dec 2023 22:51:07 +0300 Subject: [PATCH] autobuild python3 --- tasks/build-python.yml | 50 ++++++++++++++++++++++++++++++++++++++++++ tasks/centos_units.yml | 22 ------------------- tasks/main.yml | 4 +++- 3 files changed, 53 insertions(+), 23 deletions(-) create mode 100644 tasks/build-python.yml diff --git a/tasks/build-python.yml b/tasks/build-python.yml new file mode 100644 index 0000000..0b142ff --- /dev/null +++ b/tasks/build-python.yml @@ -0,0 +1,50 @@ +--- +- name: check sys python version + shell: "python3 -V | awk '{print $2}'" + register: sys_python_version + +- name: check opt python exists + stat: + path: /usr/local/opt/python-3.9/bin/python3.9 + register: opt_python + when: sys_python_version.stdout is version('3.9.0', '<') + +- name: print python info + debug: + msg: + - "Python sys version: {{ sys_python_version.stdout }}" + - "Python opt version doesn't exist" + - "Python opt version will build" + when: sys_python_version.stdout is version('3.9.0', '<') and opt_python.stat.exists == False + +- name: build python opt version + shell: | + wget https://git.hmp.today/pavel.muhortov/utils/raw/branch/master/build-python.sh + chmod u+x ./build-python.sh + ./build-python.sh qn 3.9.5 + rm ./build-python.sh + when: sys_python_version.stdout is version('3.9.0', '<') and opt_python.stat.exists == False + args: + warn: false + +- name: check that the sendmail-reboot.sh exists + stat: + path: /etc/init.d/sendmail-reboot.sh + register: sendmail_reboot + +- name: replace python interpriter, if sendmail-reboot.sh exist + shell: sed -i "s,python3,\/usr\/local\/opt\/python-3.9\/bin\/python3.9," /etc/init.d/sendmail-reboot.sh + when: sendmail_reboot.stat.exists and sys_python_version.stdout is version('3.9.0', '<') + args: + warn: false + +- name: check that the sendmail-login.sh exists + stat: + path: /etc/profile.d/sendmail-login.sh + register: sendmail_login + +- name: replace python interpriter, if sendmail-login.sh exist + shell: sed -i "s,python3,\/usr\/local\/opt\/python-3.9\/bin\/python3.9," /etc/profile.d/sendmail-login.sh + when: sendmail_login.stat.exists and sys_python_version.stdout is version('3.9.0', '<') + args: + warn: false diff --git a/tasks/centos_units.yml b/tasks/centos_units.yml index 459e461..83e0c51 100644 --- a/tasks/centos_units.yml +++ b/tasks/centos_units.yml @@ -18,25 +18,3 @@ - name: install Telegram init script link shell: cmd: "chkconfig --add /etc/init.d/sendtelegram-reboot.sh" - -- name: check that the sendmail-reboot.sh exists - stat: - path: /etc/init.d/sendmail-reboot.sh - register: stat_result - -- name: replace python interpriter, if sendmail-reboot.sh exist - shell: sed -i "s/python3/\/usr\/local\/bin\/python3.9/" /etc/init.d/sendmail-reboot.sh - when: stat_result.stat.exists - args: - warn: false - -- name: check that the sendtelegram-login.sh exists - stat: - path: /etc/profile.d/sendtelegram-login.sh - register: stat_result - -- name: replace python interpriter, if sendtelegram-login.sh exist - shell: sed -i "s/python3/\/usr\/local\/bin\/python3.9/" /etc/profile.d/sendtelegram-login.sh - when: stat_result.stat.exists - args: - warn: false \ No newline at end of file diff --git a/tasks/main.yml b/tasks/main.yml index 16e1eb0..f46fc34 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -11,4 +11,6 @@ - include_tasks: debian_units.yml when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' -- include_tasks: configs-and-scripts.yml \ No newline at end of file +- include_tasks: configs-and-scripts.yml + +- include_tasks: build-python.yml \ No newline at end of file