Skip to main content

Posts

Showing posts with the label command

Useful ansible stuff

inventory_hostname ‘ inventory_hostname ‘ contains the name of the current node being worked on…. (as in, what it is defined in your hosts file as) so if you want to skip a task for a single node – - name: Restart amavis service: name=amavis state=restarted when: inventory_hostname != "boris" (Don’t restart Amavis for boris,  do for all others). You could also use : ... when: inventory_hostname not in groups['group_name'] ... if your aim was to (perhaps skip) a task for some nodes in the specified group.   Need to check whether you need to reboot for a kernel update? If /vmlinuz doesn’t resolve to the same kernel as we’re running Reboot Wait 45 seconds before carrying on… - name: Check for reboot hint. shell: if [ $(readlink -f /vmlinuz) != /boot/vmlinuz-$(uname -r) ]; then echo 'reboot'; else echo 'no'; fi ignore_errors: true register: reboot_hint - name: Rebooting ... command: shutdown -r now "Ansible kernel update applied...

Creating a pipeline in GoCD

If you haven’t installed GoCD yet, you can follow the  GoCD Installation Guide  to install the GoCD Server and at least one GoCD Agent. This is a good point to stop and learn about the first concept in GoCD. Concept 1: Server and agents In the GoCD ecosystem, the server is the one that controls everything. It provides the user interface to users of the system and provides work for the agents to do. The agents are the ones that do any work (run commands, do deployments, etc) that is configured by the users or administrators of the system. The server does not do any user-specified “work” on its own. It will not run any commands or do deployments. That is the reason you need a GoCD Server and at least one GoCD Agent installed before you proceed. Once you have them installed and running, you should see a screen similar to this, if you navigate to the home page in a web browser (defaults to:  http://localhost:8153 ): GoCD’s new pipeline page If you have installed t...

Creating a pipeline in GoCD

If you haven't installed GoCD yet, you can follow the  GoCD Installation Guide  to install the GoCD Server and at least one GoCD Agent. This is a good point to stop and learn about the first concept in GoCD. Concept 1: Server and agents In the GoCD ecosystem, the server is the one that controls everything. It provides the user interface to users of the system and provides work for the agents to do. The agents are the ones that do any work (run commands, do deployments, etc) that is configured by the users or administrators of the system. The server does not do any user-specified "work" on its own. It will not run any commands or do deployments. That is the reason you need a GoCD Server and at least one GoCD Agent installed before you proceed. Once you have them installed and running, you should see a screen similar to this, if you navigate to the home page in a web browser (defaults to:  http://localhost:8153 ): GoCD's new pipeline page If you have installed the GoCD ...

How to Trace Execution of Commands in Shell Script with Shell Tracing

In this article of the shell script debugging series, we will explain the third shell script debugging mode, that is shell tracing and look at some examples to demonstrate how it works, and how it can be used. The previous part of this series clearly throws light upon the two other shell script debugging modes: verbose mode and syntax checking mode with easy-to-understand examples of how to enable shell script debugging in these modes. Shell tracing simply means tracing the execution of the commands in a shell script. To switch on shell tracing, use the -x debugging option. This directs the shell to display all commands and their arguments on the terminal as they are executed. We will use the sys_info.sh shell script below, which briefly prints your system date and time, number of users logged in and the system uptime. However, it contains syntax errors that we need to find and correct. #!/bin/bash #script to print brief system info ROOT_ID="0" DATE=`date` NO_USERS=`who |...

Linux commands

sudo!! : Forgot to run a command with sudo? You need not re-write the whole command, just type "sudo!!" and the last command will run with sudo. 2. Python -m SimpleHTTPServer : Creates a simple web page for the current working directory over port 8000. 3. mtr : A command which is a combination of 'ping' and 'traceroute' command. 4. Ctrl+x+e : This key combination fires up, an editor in the terminal, instantaneously. 5. nl : Outputs the content of text file with lines Numbered. 6. shuf : Randomly selects line/file/folder from a file/folder. 7. ss : Outputs Socket Statistics. 8. Last: Want to know history of last logged in users? This command comes to rescue here. 9. curl ifconfig.me : Shows machine's external IP Address. 10. tree : Prints files and folders in tree like fashion, recursively. 11. Pstree : Prints running processes with child processes, recursively. 13. stat : Shows the status information of a file as well as of a file system. 15. Pv : outputs ...