If you need to update a Python script that is in GIT and scheduled to run via an Ansible Tower project, the process is simple and easy.
Firstly you'll need:
- GitHub Access
- Ansible Tower Access
- GitHub Client (including Git CMD)
- Notepad++ (or your text editor of choice)*
*Since we're editing Python code, you might want to check out PyCharm (I still use Notepad++)
1) Git Clone
Create a folder for the Git projects, then open up Git CMD and navigate to your projects folder.
From here, run Git Clone:
git clone https://[GITHUB_FQDN]/[USER/GROUP]/[PROJECT]
Note: If you've already downloaded the project, you could just rename the downloaded folder to keep as a backup, or it will overwrite.
2) Modify the Python in your text editor
3) Commit the Code to Github
Once you're happy with your changes (they've been tested), then we commit the updated code to GitHub.
# To see the differences (:q to quit output):
# Add recent changes to reference:
git add *
# Commit code locally:
git commit -m "YOUR COMMENT"
# Pull changes that other developer would have committed:
# Push changes that you made:
4) Ansible Tower: Get Latest SCM Revision
Log into Ansible Tower, find your project, and click on the button 'Get latest SCM revision'.
Finally, verify everything is working correctly. If all is good then job done!
Post a Comment