[HOW TO] Puppet Validation of Exec[generating file] failed: '....' is not qualified and no path was specified. Please qualify the command or specify a path

I just run executable resource in Puppet and could not run successful. Here is content of Puppet file.
root@puppet:/etc/puppet/manifests# cat exec.pp
exec { 'generating file':
cwd => '/tmp/',
command => 'for i in {1.2}.txt; do touch $name; done',
creates => '/tmp/1.txt',
}
root@puppet:/etc/puppet/manifests# puppet apply --noop exec.pp
Notice: Compiled catalog for puppet in environment production in 0.10 seconds
Error: Validation of Exec[generating file] failed: 'for name in {1.2}.txt; do touch $name; done' is not qualified and no path was specified. Please qualify the command or specify a path. at /etc/puppet/manifests/exec.pp:5

Following the notification, I should declare the qualified path of command, then I put a default path as /bin
root@puppet:/etc/puppet/manifests# vim exec.pp
exec { 'generating file':
cwd => '/tmp/',
path => '/bin',
command => 'for name in {1.2}.txt; do touch $name; done',
creates => '/tmp/1.txt',
}
root@puppet:/etc/puppet/manifests# puppet apply --noop exec.pp
Notice: Compiled catalog for puppet in environment production in 0.10 seconds
Notice: /Stage[main]/Main/Exec[generating file]/returns: current_value notrun, should be 0 (noop)
Notice: Class[Main]: Would have triggered 'refresh' from 1 events
Notice: Stage[main]: Would have triggered 'refresh' from 1 events
Notice: Finished catalog run in 0.04 seconds

It works!!!

So you can do like me to fix it.

Tiến Phan - R0039

Knowledge is Endless

Sharing for Success

[HOW TO] create a shadow hash of password

Sometimes, you may need to create a critical script to change the password of root or another user. Of course, you don't use the clear text of password. It is very risk and can leak. Then, what should we do on this case?

I want to bring you focus /ect/shadow. For sure, it is salted hash file where stores all of user's password. And it already hashed. 

It looks like this


catrulez:$6$3lOhJgJD$lUKZ0Q9LHT6YO3u1pS/0hM9yJOYTkqOh/XaR2O5xYwaPKI6TWIOEjYQSsa2XWJI7Ty.i2XQmHVdqNZDnGYiUT.:17482:0:99999:7:::

and 
$6$3lOhJgJD$lUKZ0Q9LHT6YO3u1pS/0hM9yJOYTkqOh/XaR2O5xYwaPKI6TWIOEjYQSsa2XWJI7Ty.i2XQmHVdqNZDnGYiUT

is the shadow hash corresponding to its password. 

So, in my imagination, I will create a shadow hash of password what I want to set for individual user and put it to critical script. Then it should be fine. 

Two steps:
1. Create a shadow hash 
root@catrulez:~# openssl passwd -1 -salt dsadsadd Zxcvbnm1$1$dsadsadd$y4h9pSp/9rS2kVv7x4xRB.

2. Create a user with shadow hash of password. 
root@catrulez:~# useradd -p '$1$dsadsadd$y4h9pSp/9rS2kVv7x4xRB.'  user_name

Also you can take them to script. Please clear bash history. 

Tiến Phan - R0039

Knowledge is Endless

Sharing for Success

[HOW TO] black list Postfix

Once upon a time I met a problem with Postfix. The customer sent to me the ticket, in this she told me that she received many email spams from @e-m-a-i-l.com

Politely I said to her that I will find the solution for this case. So, she can save time. I drank a cup of water before discovering.

In the first, I have to check the log to find the exactly email who is spammer?
So easy, because the customer sent me the email of spammer. Next, I went to postfix log to find out.
One moment in time, I found that.

So, I need to add the spammer to postfix's black-list file.
Firstly, I created the black-list file:
#vim /etc/postfix/sender_access

#DISCARD: the sender don't receive the response 
#REJECT: the sender receives the response.

And then, I created the postfix's database
postmap hash:/etc/postfix/sender_access

I added the paragraph below to /etc/postfix/main.conf 
smtpd_recipient_restrictions = check_sender_access hash:/etc/postfix/sender_access 

Restart to apply the change
service postfix restart

After that, I opened the Postfix's log and keep my eyes. I didn't see any email from w.morrison@gmail.com.

Tiến Phan - R0039

Knowledge is Endless

Sharing for Success

[HOW TO] get the server ID in MySQL

Sometimes, you have to know the Server ID of MySQL, and you don't know how to get it?

Here I show you.

What is Server ID? 
Server always use in MySQL Replication. It defines in numeric to classify the server.

As always, server ID 1 is master server. Then server ID n+1 is slave server.

How to find it?
You use below MySQL command
# Get MySQL server_id
mysql> SHOW VARIABLES LIKE 'server_id';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| server_id     | 1     |
+---------------+-------+
1 row in set (0.01 sec)

# Change MySQL server_id
mysql>  SET GLOBAL server_id=21


Tiến Phan - R0039

Knowledge is Endless

Sharing for Success