Create a Java path entry for all users

I install Java on all my machines and used to add the java path and home variables to the user (or my user) bash profile but every time I added another user this is a manual step.

Until I found this small trick. Add a system wide profile path setting by creating a file in:

/etc/profile.d/filename

All files in profile.d are added to every users login. Much cleaner than adding it to every user’s profile.

This is the contents of my file:

/etc/profile.d/java-path.sh

export JAVA_HOME="/opt/java"
export PATH=$JAVA_HOME/bin:$PATH

These variables are set next time you log in with any user on that system.

Easy way to see your external IP from Command Line

It’s not always clear from which IP you might be reaching hosts on the internet. These IP’s are important to know since they are often the IP’s that you will whitelist on receiving systems.

The easiest way to find out what your external IP is, would be executing this command:

curl https://ipinfo.io/ip

Hope this helps 🙂

Install Python without Admin rights (windows)

Appearently it’s quite simple to install python on a windows machine, even if you don’t have admin rights.

Remember, this only works if you downloaded the MSI installer version.

Open a command line in the same folder where you downloaded the python installer (Click here for the Python download page)

Execute this command on the CLI:

msiexec /a python-2.7.16.amd64.msi /qb TARGETDIR=C:\python27

Replace the version with your downloaded version

Disable autoplay movies in Chrome

This has been annoying me for a while, a lot of sites seem to allow auto playing movies (sometimes with sound) when I visit them.

It is probably my problem, becoming a grumpy old bastard but I dislike the autoplay option.

Luckily, you can disable this feature in Chrome by opening a new tab and entering this url:

chrome://flags/#autoplay-policy

Then choose “Document user activiation is required” and you feel like you’re be back in 2017, without all this video stuff 🙂

Copy all files with Ansible Copy

I wanted to copy all files in a directory, but didn’t want to create a “with_items” because I am lazy.

The solution is to use “with_fileglob” which can use wildcards and thus select multiple files.

## Example
- name: Copying certificates to tmp
  copy:
    src: "{{ item }}"
    dest: /tmp
    owner: apache
    group: apache
    mode: 0600
  with_fileglob:
    - "files/tmp/*"

This will copy all files in the tmp folder to the client.

Ps. Another option is to use synchronize, but you need rsync on the host and client which is why I prefer copy.

Ansible – Continue nicely when shell exits with error

Sometimes a command gives an exit code which isn’t considered an error in your playbook. You could use “ignore_errors” but it will stand out when you run your playbook, and it’s the first thing new colleagues point out when we run a play together.

This example shows you how to use the exit code in a when clause without ansible throwing (and catching) the exception.

- name: Check if md5sum of the current  is the same
  shell: 'md5sum --check /install/md5sum_of_installer'
  register: installer_md5sum_check
  failed_when: ( installer_md5sum_check.rc not in [ 0, 1 ] )

- name: Run Installer if md5sum is different or missing
  include_role:
    name: my_install_role
  when: installer_md5sum_check.rc == 1
  ## rc 0: the md5sum output was "OK", thus was already installed
  ## rc 1: it was not the same (or the file was missing)

- name: Create md5sum for the installer
  shell: 'md5sum /install/my_installer.zip > /install/md5sum_of_installer'
  when: installer_md5sum_check.rc == 1
  ## We can only arrive here when the installer role was successfully finished

Use Skype with microphone in your Citrix Receiver session on Linux

Today I wanted to join a meeting but I was unable to be heard.
I’m connected to a Windows desktop via Citrix Receiver, I’m connecting from an Ubuntu Linux host.
Looking at the sound settings in my windows desktop, I saw that there was no recording device. So not being able to send sound makes sense then.
To enable input sound, add the following line to the WFClient section in your personal ICA settings file:
 
~/.ICAClient/wfclient.ini

[...]
[WFClient]
AllowAudioInput=True
[...]

Next, log off and log back into to your windows desktop and check the recording tab on the Sound settings, there a recording device now.
2018-08-31 08:20:43 screenshot
That should do the trick.

Weblogic LDAP backup (daily, and also very very simple)

My new colleague pointed me in the right way while I was scripting waaaaay too much to create a backup of the Weblogic users and groups.
The easiest way is to use the daily backup which is created by weblogic itself.
 
The backup is located on de adminserver, in this location:
$base_domain/servers/AdminServer/data/ldap/backup/EmbeddedLDAPBackup.zip
 
If there’s an issue with your embedded ldap, you can stop the adminserver, restore these files to this location:
$base_domain/servers/AdminServer/data/ldap/ldapfiles
Continue reading “Weblogic LDAP backup (daily, and also very very simple)”

FATAL Fatal error during KafkaServer startup, NumberFormatException

This might have taken me a long time to figure out, but fortunately my super awesome colleague (nicknamed Mr.T, he also pities fools) showed me the solution.
We ran into a Kafka Broker which was not starting, and gave the exception that is pasted in the bottom of this post.

FATAL Fatal error during KafkaServer startup. [..] java.lang.NumberFormatException

The solution is that the string (in this example “hs_err_pid19313”) is actually an error log which exists in a topic partition directory. (Re)move this file and Kafka will start without a problem.
(Tip: use find and grep to quickly find the file, go to your Kafka storage directory and run the following command;

find . |grep hs_err_pid19313

Continue reading “FATAL Fatal error during KafkaServer startup, NumberFormatException”