Update deb_packages ansible

Adjusted rng-tools binary path.
Removed redundant distribution, since we can just use the branch
directly.
Removed checks related to the master branch.
This commit is contained in:
ionutboangiu
2023-10-06 12:29:21 -04:00
committed by Dan Christian Bogos
parent ffcc0045c4
commit 689a78f09c
3 changed files with 45 additions and 55 deletions

View File

@@ -12,11 +12,11 @@ DscOverride: override.testing
Origin: apt.cgrates.org
Label: apt.cgrates.org
Suite: nightly
Codename: nightly
Suite: master
Codename: master
Architectures: amd64
Components: main
Description: CGRateS APT Nightly repository
Description: CGRateS master APT repository
SignWith: yes
DebOverride: override.testing
DscOverride: override.testing

View File

@@ -4,7 +4,7 @@
template:
src: gpg.conf.j2
dest: "{{ gpg_home }}/.gnupg/gpg.conf"
mode: '0600'
mode: "0600"
owner: "{{ rootUser }}"
- name: copy default template for gpg key generation
@@ -12,33 +12,34 @@
template:
src: gen-key-script
dest: "{{ gpg_home }}/.gnupg/gen-key-script-{{ rootUser }}"
mode: '0600'
mode: "0600"
owner: "{{ rootUser }}"
- name: create some required file
# Not sure what this task does, or if it's needed.
- name: List available GPG secret keys
become: true
shell: "gpg --list-secret-keys --keyid-format LONG"
- name: When starting fresh we need to make sure we have rng-tools
# rng-tools might not be needed on newer kernel versions
- name: Install rng-tools-debian
become: true
apt:
name: rng-tools
name: rng-tools-debian
state: present
ignore_errors: true
- name: Add HRNGDEVICE=/dev/urandom so we can execute rngd
become: true
lineinfile:
path: /etc/default/rng-tools
path: /etc/default/rng-tools-debian
line: HRNGDEVICE=/dev/urandom
insertafter: last
- name: generate randomness
become: true
shell: "sudo /etc/init.d/rng-tools restart"
shell: "sudo /etc/init.d/rng-tools-debian restart"
ignore_errors: true
- name: generate gpg key
become: true
shell: "sudo gpg --batch --gen-key {{ gpg_home }}/.gnupg/gen-key-script-{{ rootUser }}"

View File

@@ -1,18 +1,13 @@
---
- hosts: apt
vars:
# CGRateS vars
cgrates_dir: "/home/{{ user }}/go/src/github.com/cgrates/cgrates"
cgrates_branch: "v0.10"
cgrates_distribution: "nightly"
###############################################################
######################## GPG Vars #############################
###############################################################
gpg_home: "/root"
gpg_realname: "CGRateS"
gpg_useremail: "cgrates@itsyscom.com"
gpg_pubkeyfileexport: "apt.cgrates.org.gpg.key"
gpg_keylength: 2048
gpg_subkeylength: 2048
gpg_expire: 360
@@ -30,19 +25,11 @@
remote_user: "{{ user }}"
tasks:
- name: set cgrates cgrates_distribution
set_fact:
cgrates_distribution: "{{ cgrates_distribution }}"
###########################################################################################################################
###########################################################################################################################
# install dependencies
- name: Install dependencies
become: yes
apt: name={{ dependencies }} state=present
###########################################################################################################################
###########################################################################################################################
# Prepare for configuration
- name: Config reprepro
- name: Configure reprepro
include: reprepro.yaml
- name: Generate GPG Key
@@ -65,9 +52,6 @@
masked: no
enabled: yes
###########################################################################################################################
###########################################################################################################################
# Install Go
- name: Install Go
import_role:
name: ../roles/go
@@ -166,30 +150,21 @@
shell: "sudo ls /var/packages/debian/incoming/ | grep '.changes'"
register: changesFileNames
# get reprepro version
- name: set cgrates distribution
set_fact:
cgrates_distribution: "{{ cgrates_branch }}"
when: cgrates_branch != "master"
# Include the package with reprepro
- name: Include the package with reprepro
become: yes
command: sudo reprepro -A amd64 -Vb . include {{ cgrates_distribution }} /var/packages/debian/incoming/{{ item }}
command: sudo reprepro -A amd64 -Vb . include {{ cgrates_branch }} /var/packages/debian/incoming/{{ item }}
ignore_errors: true
args:
chdir: /var/packages/debian
with_items: "{{ changesFileNames.stdout_lines }}"
when: cgrates_branch == "master" or gitTagVar.stdout_lines|length > 0
when: gitTagVar.stdout_lines|length > 0
# Move the file to PKG server
- name: Copy the file to PKG server
shell: "scp /var/packages/debian/incoming/{{ item }} {{ pkgAddr }}:/tmp/"
args:
chdir: /var/packages/debian/incoming/
with_items: "{{ debFileName.stdout_lines }}"
# Clean the incoming folder
- name: Clean the incoming folder
become: yes
shell: "sudo rm /var/packages/debian/incoming/*"
@@ -198,36 +173,50 @@
- hosts: pkg
vars:
ansible_python_interpreter: auto # to disable deprication warning related to the use of python2
remote_user: "{{ user }}"
nginx_user: "www-data"
cgrates_branch: "v0.10"
tasks:
- name: set cgrates cgrates_distribution
set_fact:
cgrates_distribution: "{{ hostvars['apt']['cgrates_distribution'] }}"
- name: Add user to www-data group
become: yes
user:
name: "{{ user }}"
groups: "{{ nginx_user }}"
append: yes
- name: Creates directory
become: yes
file:
path: /var/packages/deb/{{ cgrates_distribution }}/
path: /var/packages/deb/{{ cgrates_branch }}/
state: directory
mode: "0775"
owner: "{{ nginx_user }}"
group: "{{ nginx_user }}"
- name: Remove symlink from current deb package
become: yes
file:
path: /var/packages/deb/{{ cgrates_distribution }}/cgrates_current_amd64.deb
path: /var/packages/deb/{{ cgrates_branch }}/cgrates_current_amd64.deb
state: absent
when: cgrates_distribution == "nightly" or hostvars['apt']['gitTagVar'].stdout_lines|length > 0
when: hostvars['apt']['gitTagVar'].stdout_lines|length > 0
- name: Move the new package to /var/packages/deb
become: yes
shell: "sudo mv /tmp/{{ item}} /var/packages/deb/{{ cgrates_distribution }}/"
become: true
shell: "mv /tmp/{{ item}} /var/packages/deb/{{ cgrates_branch }}/"
with_items: "{{ hostvars['apt']['debFileName']['stdout_lines'] }}"
- name: Set ownership and permissions for moved files
become: yes
file:
path: "/var/packages/deb/{{ cgrates_branch }}/{{ item }}"
owner: "{{ nginx_user }}"
group: "{{ nginx_user }}"
mode: "0775"
loop: "{{ hostvars['apt']['debFileName']['stdout_lines'] }}"
- name: Create the new symlink cgrates_current_amd64.deb
become: yes
file:
src: /var/packages/deb/{{ cgrates_distribution }}/{{ item }}
dest: /var/packages/deb/{{ cgrates_distribution }}/cgrates_current_amd64.deb
src: /var/packages/deb/{{ cgrates_branch }}/{{ item }}
dest: /var/packages/deb/{{ cgrates_branch }}/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
when: hostvars['apt']['gitTagVar'].stdout_lines|length > 0