Skip to content

Commit

Permalink
optimize role get_pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
zakzhu committed Dec 15, 2020
1 parent 2bb7690 commit 127b45f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 22 deletions.
37 changes: 17 additions & 20 deletions roles/get_pkg/tasks/extract_binary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,23 @@
list_files: yes
register: unpack_result

- set_fact:
- name: set variable archive_root
set_fact:
archive_root: "{{ unpack_result['files'][0] }}"

- name: "<r_get_pkg_t_extract> copy a file to {{ deploy_root }}/install/{{ package_fullname }}"
copy:
# if path ends with "/", only inside contents of that
# directory are copied to destination.
# if it does not end with "/", the directory itself
# with all contents is copied.
src: "{{ deploy_root }}/install/{{ archive_root }}"
dest: "{{ deploy_root }}/install/{{ package_fullname }}"
owner: root
group: root
mode: "0755"
#backup: yes
# The validation command to run before copying into place.
# E.g. `validate: /usr/sbin/visudo -csf %s`
#validate:
- name: "<r_get_pkg_t_extract> rename the file to {{ deploy_root }}/install/{{ package_fullname }}"
command:
#become: yes
#become_method: su
#become_user:
#become_flags: "-s /bin/sh"
args:
cmd: "mv {{ archive_root }} {{ package_fullname }}"
chdir: "{{ deploy_root }}/install"
# A filename or (since 2.0) glob pattern.
# If it already exists, this step *won't* be run.
creates: "{{ package_fullname }}"

- name: "<r_get_pkg_t_extract> remove {{ deploy_root }}/install/{{ archive_root }}"
file:
path: "{{ deploy_root }}/install/{{ archive_root }}"
state: absent
# A filename or (since 2.0) glob pattern.
# If it already exists, this step *will* be run.
#remove:
3 changes: 2 additions & 1 deletion roles/get_pkg/tasks/extract_source.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@
list_files: yes
register: unpack_result

- set_fact:
- name: set variable archive_root
set_fact:
archive_root: "{{ unpack_result['files'][0] }}"
2 changes: 1 addition & 1 deletion roles/get_pkg/tasks/verify_checksum.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

- name: "<r_get_pkg_t_verify_checksum> verify checksum of {{ package_tarball }}"
fail:
msg: "The package is corrupted, please try again!" # not required. The customized message used for failing execution. If omitted, fail will simply bail out with a generic message.
msg: "The package is corrupted, please try again!"
when: checksum != package['checksum']
vars:
checksum: "{{ checksum_result['stdout'].split('= ')[1] }}"

0 comments on commit 127b45f

Please sign in to comment.