From accc156fdfe5b849830f43afcb60baea03f9e205 Mon Sep 17 00:00:00 2001 From: TeoV Date: Mon, 22 Jun 2020 17:14:06 +0300 Subject: [PATCH] Update ansible scripts to work on centOs --- data/ansible/rpm_packages/gpg-gen-key.yaml | 3 +- data/ansible/rpm_packages/main.yaml | 56 ++++++++-------------- data/ansible/rpm_packages/nginx.yaml | 11 ++--- 3 files changed, 24 insertions(+), 46 deletions(-) diff --git a/data/ansible/rpm_packages/gpg-gen-key.yaml b/data/ansible/rpm_packages/gpg-gen-key.yaml index b13eb01f1..1db6fea5a 100644 --- a/data/ansible/rpm_packages/gpg-gen-key.yaml +++ b/data/ansible/rpm_packages/gpg-gen-key.yaml @@ -21,7 +21,7 @@ - name: When starting fresh we need to make sure we have rng-tools become: true - apt: + yum: name: rng-tools state: present ignore_errors: true @@ -32,6 +32,7 @@ path: /etc/default/rng-tools line: HRNGDEVICE=/dev/urandom insertafter: last + create: yes - name: generate randomness become: true diff --git a/data/ansible/rpm_packages/main.yaml b/data/ansible/rpm_packages/main.yaml index dddd358f5..3e7d84eff 100644 --- a/data/ansible/rpm_packages/main.yaml +++ b/data/ansible/rpm_packages/main.yaml @@ -1,16 +1,3 @@ ---- -- name: Check and set python version on YUM server - hosts: yum - remote_user: '{{ gouser }}' - gather_facts: false - tasks: - - name: symlink /usr/bin/python -> /usr/bin/python3 - raw: | - if [ -f /usr/bin/python3 ] && [ ! -f /usr/bin/python ]; then - ln --symbolic /usr/bin/python3 /usr/bin/python; - fi - become: true - - name: Check and set python version on PKG server hosts: pkg remote_user: '{{ gouser }}' @@ -63,17 +50,6 @@ customPath: "{{ lookup('env','PATH') }}:{{ golang_gopath }}/bin:/usr/local/go/bin:{{ ansible_env.PATH }}" - dependencies: - - build-essential - - git - - devscripts - - nginx - - rpm - - createrepo - - wget - - sshpass - - gnupg2 - remote_user: '{{ gouser }}' tasks: - name: set cgrates cgrates_distribution @@ -82,13 +58,26 @@ ########################################################################################################################### ########################################################################################################################### # install dependencies + - name: Add epel-relase repo so we can install sshpass + become: true + shell: "yum install epel-release -y" + - name: Install dependencies become: yes - apt: name={{ dependencies }} state=present + yum: + name: + - git + - nginx + - rpm + - rpm-sign + - createrepo + - wget + - gnupg2 + - sshpass + state: present ########################################################################################################################### ########################################################################################################################### # Prepare for configuration - # get yum version - name: set cgrates distribution set_fact: cgrates_distribution: "{{ cgrates_branch }}" @@ -111,7 +100,7 @@ - name: Check if NGINX needs to be configured become: true - shell: "ls /etc/nginx/sites-enabled | grep 'yum.cgrates.org.vhost'" + shell: "ls /etc/nginx/conf.d/ | grep 'yum.cgrates.org.vhost.conf'" ignore_errors: true register: nginxConfig @@ -216,13 +205,6 @@ args: chdir: '{{ cgrates_dir }}' - - name: symbol link - become: yes - file: - src: "{{ cgrates_dir }}/data" - dest: "/usr/share/cgrates" - state: link - - name: get git tag shell: "git tag -l --points-at HEAD" args: @@ -297,7 +279,7 @@ register: yumFiles when : cgrates_branch == "master" or gitTagVar.stdout_lines|length > 0 - # Clean the folder + #Clean the folder - name: Clean the incoming folder become: yes shell: "sudo rm -rf /var/packages/yum/{{ cgrates_distribution }}/*" @@ -308,7 +290,7 @@ command: mv cgr_build/RPMS/x86_64/{{ item }} /var/packages/yum/{{ cgrates_distribution }}/ with_items: "{{ rmpFileName.stdout_lines }}" when: (cgrates_branch == "master" or gitTagVar.stdout_lines|length > 0) and rmpFileName.stdout_lines|length > 0 - + - name: Include the package with createrepo become: yes shell: createrepo /var/packages/yum/{{ cgrates_distribution }} @@ -321,7 +303,7 @@ state: absent with_items: "{{ rmpFileName.stdout_lines }}" when: cgrates_branch != "master" and gitTagVar.stdout_lines|length == 0 - + - hosts: pkg remote_user: '{{ gouser }}' tasks: diff --git a/data/ansible/rpm_packages/nginx.yaml b/data/ansible/rpm_packages/nginx.yaml index 24718ddc4..7893e6f80 100644 --- a/data/ansible/rpm_packages/nginx.yaml +++ b/data/ansible/rpm_packages/nginx.yaml @@ -3,17 +3,12 @@ become: true template: src: nginx.conf.j2 - dest: "/etc/nginx/sites-available/yum.cgrates.org.vhost" + dest: "/etc/nginx/conf.d/yum.cgrates.org.vhost.conf" mode: '0600' owner: "{{ rootUser }}" -- name: Create a symlink for yum.cgrates.org - become: true - file: - src: "/etc/nginx/sites-available/yum.cgrates.org.vhost" - dest: "/etc/nginx/sites-enabled/yum.cgrates.org.vhost" - state: link + - name: Restart the nginx so the change take effects become: true - shell: "/etc/init.d/nginx reload" + shell: "sudo systemctl restart nginx"