Updated rpm ansible script

This commit is contained in:
Trial97
2020-03-04 14:57:44 +02:00
committed by Dan Christian Bogos
parent 7381e4d7e5
commit 13aec52348
3 changed files with 64 additions and 41 deletions

View File

@@ -248,6 +248,9 @@
- name: Create the new symlink cgrates_current_amd64.deb
become: yes
shell: "sudo ln -s /var/packages/deb/{{ cgrates_distribution }}/{{ item }} /var/packages/deb/{{ cgrates_distribution }}/cgrates_current_amd64.deb"
file:
src: /var/packages/deb/{{ cgrates_distribution }}/{{ item }}
dest: /var/packages/deb/{{ cgrates_distribution }}/cgrates_current_amd64.deb
state: link
with_items: "{{ hostvars['apt']['debFileName']['stdout_lines'] }}"
when : cgrates_distribution == "nightly" or hostvars['apt']['gitTagVar'].stdout_lines|length > 0

View File

@@ -1,9 +1,6 @@
{{ ansible_managed | comment }}
%global version 0.10.1~dev
%global branch 0.10
%global git_commit {{ gitVersion.stdout_lines[0] }}
%global git_short_commit {{ gitShortVersion.stdout_lines[0] }}
%define debug_package %{nil}
%global _logdir /var/log/%name
%global _spooldir /var/spool/%name
@@ -15,7 +12,7 @@ Release: {{ releaseTag }}
Summary: Carrier Grade Real-time Charging System
License: GPLv3
URL: https://github.com/cgrates/cgrates
Source0: https://github.com/cgrates/cgrates/archive/%{git_commit}.tar.gz
Source0: https://github.com/cgrates/cgrates/archive/{{ cgrates_version }}/{{ gitVersion.stdout_lines[0] }}.tar.gz
%if 0%{?fedora} > 16 || 0%{?rhel} > 6
Requires(pre): shadow-utils
@@ -34,7 +31,7 @@ CGRateS is a very fast and easy scalable real-time charging system for Telecom e
%prep
%setup -q -n %{name}-%{version} -c
mkdir -p src/github.com/cgrates
ln -sf ../../../%{name}-%{branch} src/github.com/cgrates/cgrates
ln -sf ../../../$(ls |grep %{name}-) src/github.com/cgrates/cgrates
%pre
getent group %{name} >/dev/null || groupadd -r %{name}

View File

@@ -22,7 +22,7 @@
ln --symbolic /usr/bin/python3 /usr/bin/python;
fi
become: true
- hosts: yum
vars:
###############################################################
@@ -45,6 +45,8 @@
###############################################################
# CGRateS location
cgrates_dir: "{{ golang_gopath }}/src/github.com/cgrates/cgrates"
cgrates_version: "v0.10"
cgrates_distribution: "nightly"
###############################################################
##################### GPG Vars #############################
###############################################################
@@ -86,16 +88,22 @@
###########################################################################################################################
###########################################################################################################################
# Prepare for configuration
# get yum version
- name: set cgrates distribution
set_fact:
cgrates_distribution: "{{ cgrates_version }}"
when: cgrates_version != "master"
- name: Check if /var/packages/yum directory exists
become: true
file:
path: /var/packages/yum
state: directory
- name: Check if /var/packages/yum/v0.10 directory exists
- name: Check if /var/packages/yum/{{ cgrates_distribution }} directory exists
become: true
file:
path: /var/packages/yum/v0.10
path: /var/packages/yum/{{ cgrates_distribution }}
state: directory
- name: Generate GPG Key
@@ -122,6 +130,8 @@
- name: Import the key in rpm
become: true
shell: rpm --import /var/packages/yum.cgrates.org.gpg.key
args:
warn: false
###########################################################################################################################
###########################################################################################################################
@@ -157,7 +167,7 @@
dest: '{{ cgrates_dir }}'
update: yes
force: yes
version: v0.10
version: "{{ cgrates_version }}"
become: yes
become_user: "{{ gouser }}"
@@ -224,9 +234,9 @@
- name: Download the tar.gz for the last commit
become: yes
shell: wget https://github.com/cgrates/cgrates/archive/v0.10/{{ gitVersion.stdout_lines[0] }}.tar.gz
args:
chdir: cgr_build/SOURCES
get_url:
url: https://github.com/cgrates/cgrates/archive/{{ cgrates_version }}/{{ gitVersion.stdout_lines[0] }}.tar.gz
dest: cgr_build/SOURCES/{{ gitVersion.stdout_lines[0] }}.tar.gz
- name: Add cgrates.spec in SPECS
become: yes
@@ -247,63 +257,76 @@
# Move the file to PKG server
- name: Copy the file to PKG server
shell: 'sshpass -p {{ pkgPass }} scp cgr_build/RPMS/x86_64/{{ rmpFileName.stdout_lines[0] }} {{ gouser }}@{{ internalPkgAddr }}:/tmp/'
shell: 'sshpass -p {{ pkgPass }} scp cgr_build/RPMS/x86_64/{{ item }} {{ gouser }}@{{ internalPkgAddr }}:/tmp/'
with_items: '{{ rmpFileName.stdout_lines }}'
- name: Sign with rpm --addsign the .rpm file
become: yes
shell: 'sudo rpm --addsign cgr_build/RPMS/x86_64/{{ rmpFileName.stdout_lines[0] }}'
when : gitTagVar.stdout_lines|length > 0
shell: 'sudo rpm --addsign cgr_build/RPMS/x86_64/{{ item }}'
with_items: "{{ rmpFileName.stdout_lines }}"
when : cgrates_version == "master" or gitTagVar.stdout_lines|length > 0
- name: Check if is something in /var/packages/yum/v0.10/
- name: Check if is something in /var/packages/yum/{{ cgrates_distribution }}
become: yes
shell : "ls /var/packages/yum/v0.10/"
shell : "ls /var/packages/yum/{{ cgrates_distribution }}/"
register: yumFiles
when : gitTagVar.stdout_lines|length > 0
when : cgrates_version == "master" or gitTagVar.stdout_lines|length > 0
# Clean the folder
- name: Clean the incoming folder
become: yes
shell: "sudo rm -rf /var/packages/yum/v0.10/*"
when: gitTagVar.stdout_lines|length > 0 and yumFiles.stdout_lines|length > 1
shell: "sudo rm -rf /var/packages/yum/{{ cgrates_distribution }}/*"
when: (cgrates_version == "master" or gitTagVar.stdout_lines|length > 0) and yumFiles.stdout_lines|length > 1
- name: Move the files to /var/packages/yum/v0.10
- name: Move the files to /var/packages/yum/{{ cgrates_distribution }}
become: yes
command: mv cgr_build/RPMS/x86_64/{{ rmpFileName.stdout_lines[0] }} /var/packages/yum/v0.10/
when : rmpFileName.stdout_lines|length > 0 and gitTagVar.stdout_lines|length > 0
command: mv cgr_build/RPMS/x86_64/{{ item }} /var/packages/yum/{{ cgrates_distribution }}/
with_items: "{{ rmpFileName.stdout_lines }}"
when: (cgrates_version == "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/v0.10
when : gitTagVar.stdout_lines|length > 0
shell: createrepo /var/packages/yum/{{ cgrates_distribution }}
when : cgrates_version == "master" or gitTagVar.stdout_lines|length > 0
- name: Remove rpm files
become: yes
file:
path: cgr_build/RPMS/x86_64/{{ item }}
state: absent
with_items: "{{ rmpFileName.stdout_lines }}"
when: cgrates_version != "master" and gitTagVar.stdout_lines|length == 0
- hosts: pkg
remote_user: '{{ gouser }}'
tasks:
- name: set cgrates cgrates_distribution
set_fact:
cgrates_distribution: "{{ hostvars['yum']['cgrates_distribution'] }}"
- name: Creates directory rpm
- name: Creates directory
become: yes
file:
path: /var/packages/rpm/
state: directory
- name: Creates directory v0.10
become: yes
file:
path: /var/packages/rpm/v0.10/
path: /var/packages/rpm/{{ cgrates_distribution }}/
state: directory
- name: Remove symlink from current rpm package
become: yes
file:
path: /var/packages/rpm/v0.10/cgrates_current.rpm
path: /var/packages/rpm/{{ cgrates_distribution }}/cgrates_current.rpm
state: absent
when : hostvars['yum']['gitTagVar'].stdout_lines|length > 0
when : cgrates_distribution == "nightly" or hostvars['yum']['gitTagVar'].stdout_lines|length > 0
- name: Move the new package to /var/packages/rpm
become: yes
shell: "mv /tmp/{{ hostvars['yum']['rmpFileName']['stdout_lines'][0] }} /var/packages/rpm/v0.10/"
shell: "mv /tmp/{{ item }} /var/packages/rpm/{{ cgrates_distribution }}/"
with_items: "{{ hostvars['yum']['rmpFileName']['stdout_lines'] }}"
- name: Create the new symlink cgrates_current.rpm
become: yes
shell: "ln -s /var/packages/rpm/v0.10/{{ hostvars['yum']['rmpFileName']['stdout_lines'][0] }} /var/packages/rpm/v0.10/cgrates_current.rpm"
when : hostvars['yum']['gitTagVar'].stdout_lines|length > 0
file:
src: /var/packages/rpm/{{ cgrates_distribution }}/{{ item }}
dest: /var/packages/rpm/{{ cgrates_distribution }}/cgrates_current.rpm"
state: link
with_items: "{{ hostvars['yum']['rmpFileName']['stdout_lines'] }}"
when : cgrates_distribution == "nightly" or hostvars['yum']['gitTagVar'].stdout_lines|length > 0