How to Create JKS Using Ansible | Generate p12 Using Playbook | Ansible Tutorial

Tags: ansible command module, ansible pip, ansible prompt, ansible tutorial, ansible, expect module, ansible PKCS12, Ansible JKS, JKS, generate jks file, generate p12 file, linuxtopic
How to create jks using ansible ?
How to create p12 using ansible ?
How to execute a command and responds to prompts in ansible ?
How to use expect/read in ansible ?

In This topic we will create PKCS12 file and then create JKS file using expect module.

Step 1:

Go to the ansible main directory and create yml file with suitable name
cd /etc/ansiblevi p12.yml
---
- name: Use EXPECT / Read
  hosts: 127.0.0.1
  gather_facts: false

We define name and hosts entry for execution of this playbook, you can replace 127.0.0.1 with your targeted hosts or group

  tasks:

  - name: install expect
    pip: name=pexpect

pexpect python module require on Client so first we will install pexpect using pip module

  - name: Create PKCS12
    expect:
     command: openssl pkcs12 -export -in /etc/ssl/linuxtopic/linuxtopic-self-signed.crt -inkey /etc/ssl/linuxtopic/server-master.key -out  /opt/server-pkcs.p12
     responses:
       Enter Export Password: "password"
       Verifying - Enter Export Password: "password"

In 2nd task we use expect module, before use it read document,  at list run your command on hosts and copy all response like it will ask “Enter Export Password:”  you can type your response in double cote (“”) 

    Enter Export Password: "password"

ansible command module, ansible pip, ansible prompt, ansible tutorial, pexpect python module, ansible, expect module, ansible PKCS12, Ansible JKS, JKS, generate jks file, generate p12 file, linuxtopic
Generate p12 file
  
- name: Generate JKS file
    expect:
     command: keytool -importkeystore -srckeystore /opt/server-pkcs.p12 -srcstoretype pkcs12 -destkeystore /opt/server-jskfile.jsk -deststoretype JKS
     responses:
       Enter destination keystore password:  "jkspassword"
       Re-enter new password: "jkspassword"
       Enter source keystore password: "password"

3rd task: we generate JKS file using same expect module 

ansible command module, ansible pip, ansible prompt, ansible tutorial, pexpect python module, ansible, expect module, ansible PKCS12, Ansible JKS, JKS, generate jks file, generate p12 file, linuxtopic
Generate JKS file using ansible

Your playbook has been ready to execute, you can run using ansible-playbook command, just copy full playbook:

---
- name: Use EXPECT / Read
  hosts: 127.0.0.1
  gather_facts: false


  tasks:

  - name: install expect
    pip: name=pexpect


  - name: Create PKCS12
    expect:
     command: openssl pkcs12 -export -in /etc/ssl/linuxtopic/linuxtopic-self-signed.crt -inkey /etc/ssl/linuxtopic/server-master.key -out  /opt/server-pkcs.p12
     responses:
       Enter Export Password: "password"
       Verifying - Enter Export Password: "password"


  - name: Generate JKS file
    expect:
     command: keytool -importkeystore -srckeystore /opt/server-pkcs.p12 -srcstoretype pkcs12 -destkeystore /opt/server-jskfile.jsk -deststoretype JKS
     responses:
       Enter destination keystore password:  "jkspassword"
       Re-enter new password: "jkspassword"
       Enter source keystore password: "password"



Step 2:

ansible-playbook  p12.yml



Verify by checking jks and p12 file

ll  /opt/



Both files available in opt directory, means playbook working fine 



Your support is must so Please Like, share and comment on this ansible  artical.

Thanks,
www.linuxtopic.com

How to Generate SSL Certificate using Ansible | Generation CSR using Ansible


In this tutorial we will install openssl package and use following listed modules

Openssl_privatekey - To generate private key
Openssl_csr - To generate csr file
Openssl_certificate - To Generate certificate

Before we start this tutorial we read example and doc of all module
ansible-doc openssl_privatekeyansible-doc openssl_csransible-doc openssl_certificate

Step 1:

Go to ansible main directory and create yml file with suitable name
cd /etc/ansiblevi ssl-certs.yml
#We define name and hosts entry for execution of this playbook, you can replace 127.0.0.1 with your targeted hosts or group

---
- name: generate ssl certificate
  hosts: 127.0.0.1
  gather_facts: false

# For generation of SSL certs we required a openssl package so our first task is to install package on remote/localhost, 

  tasks:

  - name: Install openssl package
    yum: name=openssl state=latest

# This is optional steps to keep ssl certificate, create a directory

  - name: Create ssl directory
    file: path=/etc/ssl/linuxtopic state=directory mode=0775

# Now we will generate a private key by using a "openssl_privatekey" module 

  - name: Generate Private key
    openssl_privatekey: path=/etc/ssl/linuxtopic/server-master.key

# After generation of key we will generate csr with the help of "openssl_csr" module 

  - name: Generate CSR
    openssl_csr: 
     path: /etc/ssl/linuxtopic/linuxtopic-client.csr
     privatekey_path: /etc/ssl/linuxtopic/server-master.key 
     common_name: linuxtopic.com 
     country_name: IN
     email_address: [email protected]
     organization_name: linuxtopic

# at the end of the tasks we will generate certificate using  "openssl_certificate" module

  - name: Generate a self signed certificate
    openssl_certificate:
     csr_path: /etc/ssl/linuxtopic/linuxtopic-client.csr
     path: /etc/ssl/linuxtopic/linuxtopic-self-signed.crt
     privatekey_path: /etc/ssl/linuxtopic/server-master.key
     provider: selfsigned



Step 2:

To execute ansible playbook
ansible-playbook ssl-certs.yml


Step 3: 

To Verify 
ls -lah /etc/ssl/linuxtopic/


Your support is must so Please Like, share and comment on this ansible  artical.

Thanks,
www.linuxtopic.com

How to Create 100% Securely AWS Account Using Debit Card | AWS Free Tier Account

aws certification,  aws, aws cloud, aws console, aws login, aws training, aws cloud computing, aws server, aws tutorial, aws security, aws free training, aws free, aws full form, what is aws, linuxtopic, aws ec2, aws s3, amazon web services, cloud computing tutorial, aws iam
AWS Account
Tags: aws certification,  aws, aws cloud, aws console, aws login, aws training, aws cloud computing, aws server, aws tutorial, aws security, aws free training, aws free, aws full form, what is aws, linuxtopic, aws ec2, aws s3, amazon web services, cloud computing tutorial, aws iam
What is AWS ?

AWS - Amazon Web Service is Cloud Platform that offering over 160+ fully featured services globally.

How to Create a Free Account on AWS ?

There are following steps to Create a free account on AWS.

1 - Open Official Web Site of AWS
https://aws.amazon.com


Click on Create on Free Account - Button, it will open a Signup form

2 - Fill up Signup form with valid email address, choose password and AWS account name.

aws certification,  aws, aws cloud, aws console, aws login, aws training, aws cloud computing, aws server, aws tutorial, aws security, aws free training, aws free, aws full form, what is aws, linuxtopic, aws ec2, aws s3, amazon web services, cloud computing tutorial, aws iam
AWS Signup - Linuxtopic
Note: You can click on Sign in if you have already AWS account.

Press Continues button, For Update Contact Information, We will Select Account Type, Two option "Professional and Personal" are available, you can select according to your need, in this tutorial we will select a person.

3 -  Add your Full Name as you like, Phone Number, Select  your country from drug down menu,  Address, City, State, Postal Code then check on the AWS Agreement.



After Fill up all details, Click on "Create Account and Continues" button, it will ask you a Payment Information.

Type Credit / Debit Card details like Number, Expire date, Cardholder name.

Select your billing Address other wise click on use a new address option for add new address.

PAN Card option, As your wish to add them  otherwise select no.



Press on "Secure Submit" It will charge Rs 2 and it is  refundable after 3 - 5 business days. 

After Successfully payment, Confirm your Identity. 

4 - Select your Country Code from Drug down, add your phone number and type Security check 

 

Press "Contact me", you will received a call from AWS.



5 - Confirm your 4 digit number on your phone keypad.



Complite Video Tutorial



6 - Your Identity has been verified now press "continues"  and select your plan



There are 3 Plan Basic, Developer and Business available on AWS, select your plan according to your need. here we will select a Basic Plan by Click on "Free" Button.


Select your "My role is" and "I am interested in" from drug down menu and press submit button.

Your account has been successfully created, now you can login in your account by click on Sing in button of top right corner.