Monday, December 10, 2018

Ansible and Jinja2: Check if variable is defined and it's True

Jinja2 provides you with a built in test:
So you can simply use:

However, if you're using Ansible variables, even thought you might have defined some of them as False they might still be treated as True as Jinja2 may simply see them as string variables.
So you should, and even encouraged to use the built-in bool filter. So the final and the safest answer is this:

Monday, February 29, 2016

How to copy files/directories from list preserving directory


Create a directory 'newdir',
And run the following supplying the filelist file:


You have the following tree as in example:

Now, you have the following list of files inside `filelist.txt`:

You want to copy somewhere else only this files.
The script should run inside the `dir0` directory.
The above script will run on each row inside filelist.txt and copy them to `newdir`. `newdir` should be created before running the script.

* It does not matter if the end path is a file or directory

Wednesday, December 17, 2014

The certificate retrieved from the master does not match the agent's private key.

While implementing puppet in our environment, I got into this issue with newly created machine. Running 'puppet agent -t' for the first time:

First you must make sure the certname in puppet.conf matches the hostname of the machine, but the commands mentioned above may still not work and result in the same error.

After a little digging on the puppet master machine, I found the following file in the following path:
Just remove this agent's pem file, and redo the commands again. Fixed the issue for me.

Edit: Also ensure you are working under root in puppet master :P

Tuesday, February 18, 2014

LibreOffice 4 not opening files from smb

Just a note to myself,

It's a temporary fix, or as many call it, a workaround.

There is a bug in LO that you're not able to open files on smb share. The LO just start (may show a splash screen), and closes with no error.

The workaround is simple, as provided by Maxim Monastirsky (comment #15):

Open the .desktop file (such as /usr/share/applications/libreoffice4.1-writer.desktop for LO Writer) and comment the following line:
For Nautilus users:

For Dolphin users:
Open the same file, and comment the following line:

It's working now like a charm.

Wednesday, February 5, 2014

Can't send mail from kontact using davmail

I moved to Arch Linux recently with KDE, and tried setting my organization email account on Kontact using davmail.
It's not my first time, and I just used this steps as usual:

Everything was setup except I couldn't send email and received the following error:
Error : ErrorSendAsDenied The user account which was used to submit this request does not have the right to send mail on behalf of the specified sending account
After lot of investigation, I found out that somehow "davmail is not sending the right "From" address in new versions".
That's Ok, except I have an old davmail server, that wasn't updated for some months, and it worked before I moved to Arch.

So I tried to check the Kmail side, and after a lot of time, came up with this note in the documentation:

The way of sending messages configured here will be used for your default identity and for all other identities that do not have their own way of sending messages. You can use different ways of sending messages for different identities by selecting the Outgoing Account check box in the Advanced tab of the Identities page.
Kmail Identity Edit
Kmail Identity settings
Let's check my identity then! And I've found the culprit.
Go to Configure Kmail ->  Identities -> Choose your Identity -> Modify.
I had no email address set in my Identity, right after setting it up, the emails sent successfully!

Not sure why it happened, maybe some change in the newer version of Kmail. But that fixed it for me, and hope does the same for you!

Saturday, October 5, 2013

Deinterlacing and converting MTS video files

For my trip abroad I had a Sony video camera I borrowed from my friend. The camera was filming in AVCHD format, in 1080i format, an interlaced video.
After coming home, I was searching for the best way, to preserve quality, to deinterlace the video files and keep them that way. I have tried several ways, also tried converting with VLC only to find out that there is a bug. So I came up with the following article:

The way is to just use the command line, with the ffmpeg convert option. However, it came up to me, that the sameq option is no longer available which is used by the publisher. So I decided to publish this post, with the fix to the command. You just need to replace the sameq option with qscale 0:
ffmpeg -i in.MTS -vf yadif=1 -acodec ac3 -ab 192k -vcodec mpeg4 -f mp4 -y -qscale 0 out.mp4
Replace in.MTS with the source file and out.mp4 with the output file name.

This far it resulted in the best deinterlaced video quality I could find.
You can download ffmpeg here:

Monday, August 26, 2013

Key Update Tool throws an error

Note to self:
If Key Update Tool (A tool to update Win XP Serial Key) is giving you this error:
The product key could not be updated on your computer.  This may be due to technical difficulties or network connectivity issues.  Please contact Microsoft Support for additional assistance.
 Make sure you have turned off Trend Micro antivirus.*

*May apply to other antivirus software as well.

Tuesday, August 13, 2013

Outlook on Exchange using wrong certificate

 Many of us encountered this error:
The name on the security certificate is invalid or does not match the name of the site.
But this time, it was something different.
Not my image, but the exact error. (Source not found)
99% that it's not the solution you are looking for. But I will still fill the gap for the 1% that may encounter it.

I will explain every step I did until I found the problem. There are some solutions that I've tried that didn't work for me, but might for you, so you may try them.
*If you don't want to read it all, just jump directly to my solution down below.

The System:
SBS 2008 (server 2008 + exchange 2007)
*The solution may also apply for greater versions of exchange.

The problem:
As we began upgrading people to outlook 2010 there were errors popping about the certificate.
So the first thing I did was issuing a certificate from GoDaddy and installing it using the SBS console.
It didn't fix the problem.
The server is pretty old, and it wasn't me who installed it in the first place and it wasn't me who maintained it for several years, so I decided to go the manual way.

Thursday, April 18, 2013

Outlook 2003 hangs when replying / forwarding certain emails

I haven't posted here in a while.
Anyway, I had a user with a problem, when replying or forwarding certain messages outlook would just hang, and you would find a process "WINWORD.EXE" with 50% cpu in task manager.
So after some digging in google, I decided to read further some posts (instead of just looking at best answers) and I found this post:

Thanks John Blessing or jb[3], whoever you are. Thought no one answered you, your solution actually worked.

I quote what you need to do:
Sounds to me like a problem with Word Automation.

This is a stab in the dark:

Start menu -> run
regsvr32 ole32.dll

John Blessing
Thank you again!

Monday, February 4, 2013

Push emails (ActiveSync) suddenly not working on server 2003

Today a small business server 2003 was shut down unexpectedly (Simple electricity issue). After the server came up, the ActiveSync was no longer working. What I mean is that people who had their phones configured no longer received emails automatically by push. However the emails did sync, after going to the email app, and refreshing them.
So what's going on? Actually it's pretty simple for people that know where to look, unfortunately I forgot about the order of the things to check, and it took me a bit longer.
If you go to the Application log in Event Viewer, you will see the following error:
IP-based AUTD failed to initialize because the processing of notifications could not be setup.  Error code [0x80004005].  Verify that no other applications are currently bound to UDP port [2883], or try specifying a different port number.
Or this:
 IP-based AUTD failed to initialize.  Error code: [0x80004005].

So what's the solution?
Just restart the DNS Service. Everything was ok after that.

But, the problem may come back again. So here's the permanent solution, after reading more about that on this page, you may need to add the following ports as reserved in the registry:
  • 1645-1646 - Used by IAS
  • 1701-1701 - Used by L2TP
  • 1812-1813 - Used by IAS
  • 2883-2883 - Used by AUTD
  • 4500-4500 - Used by IPSEC
Add this to the following registry:
Now restart the server to make sure everything is fine.

Hope it helped somebody.