I have a file test_proc.init
in a particular directory. And I have one more file desc.cmd
in the same directory which has below content:
set_poc 204 6
send_data_file goldy_proc.init 4e8ee8946f7a89d2eb501a752c5e3ee6ea266e5b
set_poc 204 7
send_data_file goldy_proc.init 4e8ee8946f7a89d2eb501a752c5e3ee6ea266e5b
set_poc 204 8
send_data_file goldy_proc.init 4e8ee8946f7a89d2eb501a752c5e3ee6ea266e5b
set_poc 204 9
send_data_file goldy_proc.init 4e8ee8946f7a89d2eb501a752c5e3ee6ea266e5b
Below is what I want to do:
- I want to get the
sha1sum
oftest_proc.init
file:sha1sum test_proc.init
. - And whatever is the output from that
sha1sum
command, I want to copy that checksum and update thedesc.cmd
file.
So if new checksum is e32313118e53b60140d2024dfa7578c3fd89b346
the my desc.cmd
file will be like this:
set_poc 204 6
send_data_file goldy_proc.init e32313118e53b60140d2024dfa7578c3fd89b346
set_poc 204 7
send_data_file goldy_proc.init e32313118e53b60140d2024dfa7578c3fd89b346
set_poc 204 8
send_data_file goldy_proc.init e32313118e53b60140d2024dfa7578c3fd89b346
set_poc 204 9
send_data_file goldy_proc.init e32313118e53b60140d2024dfa7578c3fd89b346
Is this possible to do in ansible? I am not sure on how can I paste the checksum and update the file.
- name: Get sha1sum of file
stat:
path: /data/test_proc.init
checksum_algorithm: sha1sum
get_checksum: yes
register: shell_stat