pickup hostname and create self signed certificate

16 views
Skip to first unread message

visar

unread,
Nov 27, 2018, 8:18:23 AM11/27/18
to Ansible Project
Hello Experts,

i have working command for creating self signed certificate for IHS server's .kdb file and i was trying to use the same command through ansible. Here my aim is that ansible should detect the hostname of application servers and should use that name for the "-dn" of the command.

Below is the working command 

[root@myhost bin]# ./gskcmd -cert -create -db /opt/myapp/key.kdb -label IHS -expire 3650 -size 2048 -dn "CN=myserverFQDN" -default_cert yes -pw password

but below is my play and its giving syntax error

---

- name: installation
  hosts: IHS
  tasks:
    - name: get hostname
      shell: echo $HOSTNAME
      register: hostname

    - name: create self signed certificate for IHS
      command: /opt/myapp/bin/gskcmd -cert -create -db /opt/myapp/key.kdb -label IHS -expire 3650 -size 2048 -dn "CN={{ hostname}}" -default_cert yes -pw password

Bharath Kumar

unread,
Nov 27, 2018, 10:08:39 PM11/27/18
to Ansible Project
Please try the below.

---
hosts
: IHS
gather_facts
: yes

  tasks
:
 
   
- name: Create Self Signed Certificate for IHS

      command
: /opt/myapp/bin/gskcmd -cert -create -db /opt/myapp/key.kdb -label IHS -expire 3650 -size 2048 -dn "CN={{ ansible_fqdn }}" -default_cert yes -pw password

visar

unread,
Nov 28, 2018, 3:18:52 AM11/28/18
to Ansible Project
Hello Bharath,

Thanks a lot.. it worked.. appreciate your help here...
Reply all
Reply to author
Forward
0 new messages