diff --git a/data/ansible/deb_packages/main.yaml b/data/ansible/deb_packages/main.yaml index 8d48c15b3..39d8e4021 100644 --- a/data/ansible/deb_packages/main.yaml +++ b/data/ansible/deb_packages/main.yaml @@ -187,19 +187,26 @@ file_type: file register: package_files - - name: Copy package files to incoming directory + - name: Move package files to incoming directory become: true - ansible.builtin.copy: - src: "{{ item.path }}" - dest: "{{ reprepro_basedir }}/incoming/" - remote_src: true + ansible.builtin.command: mv {{ item.path }} {{ reprepro_basedir }}/incoming/ + args: + creates: "{{ reprepro_basedir }}/incoming/{{ item.path | basename }}" + removes: "{{ item.path }}" with_items: "{{ package_files.files }}" when: package_files.matched > 0 + - name: Get current git commit hash + ansible.builtin.command: git log -n1 --format=format:%h HEAD + args: + chdir: "{{ cgrates_dir }}" + register: git_commit_hash + changed_when: false + - name: Check if packages already in reprepro become: true ansible.builtin.shell: | - reprepro -b {{ reprepro_basedir }} list {{ cgrates_branch }}-{{ item.codename }} 2>/dev/null | grep -q cgrates + reprepro -b {{ reprepro_basedir }} list {{ cgrates_branch }}-{{ item.codename }} 2>/dev/null | grep -q "{{ git_commit_hash.stdout }}" register: reprepro_check changed_when: false failed_when: false @@ -237,13 +244,7 @@ - cgrates_branch == 'master' or git_tag_result.stdout_lines | length > 0 - name: Copy the file to PKG server - ansible.builtin.command: "scp {{ item.path }} {{ pkgAddr }}:/tmp/" - with_items: "{{ package_files.files }}" - - - name: Remove package files after successful sync - ansible.builtin.file: - path: "{{ item.path }}" - state: absent + ansible.builtin.command: "scp {{ reprepro_basedir }}/incoming/{{ item.path | basename }} {{ pkgAddr }}:/tmp/" with_items: "{{ package_files.files }}" rescue: @@ -307,6 +308,14 @@ path: "{{ reprepro_basedir }}/incoming" state: absent + - name: Remove leftover package files + ansible.builtin.file: + path: "{{ item }}" + state: absent + with_fileglob: + - "/home/{{ user }}/go/src/github.com/cgrates/cgrates_*" + - "/home/{{ user }}/go/src/github.com/cgrates/cgrates-dbgsym_*" + - hosts: pkg vars: nginx_user: "www-data"