Ansible: Enable Debug and Increase Verbosity

During troubleshooting of Ansible issues it is useful to know how to enable debug mode and increase the level of verbosity.

To enable debug and increase verbosity in Ansible you can pass the corresponding environment variables on the command line or define these settings in Ansible configuration file.

Warning: The debug output can also include secret information despite no_log settings being enabled, which means debug mode should not be used in production.

(more…)

Git – Remove All Commits – Clear Git History (Local & Remote)

In this article i am showing how to clear Git history by removing all commits.

You may need this if you want to delete sensitive data from the history of Git commits.

After such cleanup you will have the latest version of your Git repository, but with the one commit only.

Be aware that after resetting all the history of changes in your Git repository will be deleted as well. (more…)

Ansible: When Variable Is – Defined | Exists | Empty | True

In Ansible playbooks, it is often a good practice to test if a variable exists and what is its value.

Particularity this helps to avoid different “VARIABLE IS NOT DEFINED” errors in Ansible playbooks.

In this context there are several useful tests that you can apply using Jinja2 filters in Ansible.

In this article, i’ll show the examples of how to test a variable in Ansible: if it exists or not, if it is empty or not and if it is set to True or False. (more…)

Windows: Get Exit Code (ErrorLevel) – CMD & PowerShell

Every command or application returns an exit status, also known as a return status or exit code.

A successful command or application returns a 0, while an unsuccessful one returns a non-zero value that usually can be interpreted as an error code.

In Linux you can get the exit status of a last command by executing echo $?.

In this article i will show how to get the return code from the last console command or application in Windows using the command-line prompt (CMD) or the PowerShell. (more…)

Git – Config Username & Password – Store Credentials

To connect to a Git repository with authentication over HTTP(S), every time it needs to set a username and password.

You can configure Git to remember a username and password by storing them in a remote URL or by using Git credential helper.

In this article i am showing how to clone Git repository by setting a username and password on the command line, how to save a username and password in Git credentials storage and how to configure different usernames and passwords for different repositories on the same Git server. (more…)

Git – Create New Branch

Instead of committing directly in local master branch, a good developer creates a new branch each time he starts working on a new bug or feature.

To create a new branch there is a git branch command.

Below i will show the examples of how to create a new local branch in Git from another branch (e.g. current branch, master, develop, etc.), how to create a new branch from commit or tag and how to push a new branch to the remote Git repository (create remote branch). (more…)