Below you will find pages that utilize the taxonomy term “Shell”
Postsread more
How To Determine Your Public IP Address Programmatically From An Ansible Task
Short answer: use ipify
ipify
provides a simple public address API.
Using the tool, you can determine your public IP address programmatically. If you are using the shell:
curl 'https://api.ipify.org'
Using it in a shell script:
my_ip=$(curl 'https://api.ipify.org' -s)
echo $my_ip
Using the Ansible ipify
module:
- hosts: localhost
vars:
tasks:
- name: Get my public IP
ipify_facts:
timeout: 20
delegate_to: localhost
register: public_ip
- name: output
debug: msg="{{ ipify_public_ip }}"
Sample output of Ansible playbook execution:
ansible-playbook ipify.yml
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
PLAY [localhost] **************************************************************************************************************************************************************************************************
TASK [Gathering Facts] ********************************************************************************************************************************************************************************************
ok: [localhost]
TASK [Get my public IP] *******************************************************************************************************************************************************************************************
ok: [localhost -> localhost]
TASK [output] *****************************************************************************************************************************************************************************************************
ok: [localhost] => {
"msg": "49.206.13.205"
}
PLAY RECAP ********************************************************************************************************************************************************************************************************
localhost : ok=3 changed=0 unreachable=0 failed=0
Posts
read more
Becoming Productive In Bash Using The Keyboard Shortcuts
Moving around
You can use the arrow keys on keyboard to move around in the command line. Bash also provides convenient keyboard shortcuts to navigate effectively. Try them out and see for yourself.
To become a Bash pro user you have to get yourself familiar with the keyboard shortcuts. Once you do, you’ll find yourself productive.
Shortcut | Description |
---|---|
CTRL+b | move backward one character |
CTRL+f | move forward one character |
ESC+b | move one word backward |
ESC+f | move one word forward |
CTRL+a | move to beginning of line |
CTRL+e | move to end of line |
CTRL+p | move to previous line |
CTRL+n | move to next line |
ESC+< | move to first line of history list |
ESC+> | move to last line of history list |
Moving around words using ESC+f
and ESC+b
are my favourites in this list. Jumping to first and last lines of the
history list is also useful.