When installing some proprietary software, the documentation instructs me to run a command that creates a new authentication key, which is returned on-screen as standard output. To help automate this I created the following command: /usr/local/bin/atk-key | grep security.user.authToken= | sed -e ‘s/[1]*//’ > /tmp/auth_token.txt
The grep command searches for the newly created key, the sed command removes all whitespace in front of the newly created key and then it’s written to a text file. The resulting text file looks something like: security.user.authToken=K8gh578djrh8939Kl/583.
The value of “security.user.authToken=” will obviously change whenever its ran, so I need to configure a playbook that will copy that line from the text file into a configuration file and not be tripped up by the changing value. I’ve looked at lineinfile but am not sure how to configure a task to do what I’m asking. The start of my playbook is below:
\t ↩︎