April 2018
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
30  

Categories

April 2018
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
30  

Ansible-palybooks

Ansible-palybooks

root@controller:~$ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/home/root/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/root/.ssh/id_rsa. Your public key has been saved in /home/root/.ssh/id_rsa.pub. The key fingerprint is: 33:b8:4d:8f:95:bc:ed:1a:12:f3:6c:09:9f:52:23:d0 root@controller The key’s randomart image is: +–[ RSA […]

Managing files in ansible

Managing files in ansible

[root@controller ~]$ ansible localhost –list-hosts

hosts (1): localhost ——————————————- [root@controller ~]$ vim file.yaml — – name: creating a file hosts: localhost tasks: – file: path: /home/root/sample state: touch owner: root group: root mode: 0755 … ——————————————- [root@controller ~]$ ansible-playbook –syntax-check file.yaml

playbook: file.yaml

—————————————- [root@controller ~]$ ansible-playbook -C file.yaml

PLAY [creating […]

ansible vault

root@controller ~]# ansible-vault create mohan.yml Vault password:

[root@controller ~]# cat mohan.yml $ANSIBLE_VAULT;1.1;AES256 38623235633039636166356162393064363936303461306536386237663032383932656164633131 6132633132376266313863366164396535386539666562310a306562383834343431633536353332 63303935623030393261373030343366323361653238306531356434333538613236303738653730 3935313536396361640a343836366434613638316538333165366161306166396564353635383831 30636536366462646362373432396234383432376437633764616239393938366137

[root@controller ~]# ansible-vault view mohan.yml Vault password: hai how are you

[root@controller ~]# ansible-vault edit mohan.yml Vault password:

[root@controller ~]# ansible-vault rekey mohan.yml Vault password: New Vault password: Confirm New Vault password: Rekey successful

[root@controller ~]# ansible-playbook mohan.yml […]

JINJA2 templates in ansible

JINJA2 templates in ansible

[root@workstation ~]# ansible -m ping all 192.168.1.23 | SUCCESS => { “changed”: false, “ping”: “pong” } 192.168.1.22 | SUCCESS => { “changed”: false, “ping”: “pong” }

========================================= [root@workstation ~]# vim motd.j2 this is {{ ansible_hostname }}. today’s date is {{ ansible_date_time.date }} you can ask {{ system_owner }} for access ========================================== […]

Creating role in ansible

Creating a basic role for displaying message of the day

[root@workstation ~]# vim /etc/ansible/roles/motd/main.yml — – name: use motd role playbook hosts: all

roles: – motd

[root@workstation ~]# vim /etc/ansible/roles/motd/defaults/main.yml — system_owner: rmohan [root@workstation ~]# vim /etc/ansible/roles/motd/tasks/main.yml — – name: deliver motd file template: src: templates/motd.j2 dest: /etc/motd owner: root group: root mode: 777 [root@workstation […]

HANDLERS & register in ansible

HANDLERS & register in ansible

[root@workstation ~]# vim register.yaml — – name: checking the register module functionality hosts: localhost tasks: – name: command: ps register: output – debug: msg=”{{ output.stdout }}” ==================================================== [root@workstation ~]# ansible-playbook –syntax-check register.yaml

playbook: register.yaml

[root@workstation ~]# ansible-playbook register.yaml

PLAY [checking the register module functionality] ******************************

TASK [setup] ******************************************************************* ok: [localhost]

[…]

Tags in ansible

Tags in ansible

[root@workstation ~]# vim tags.yaml — – name: installing postfix and stopping from starting service hosts: localhost tasks: – name: installing postfix package yum: name=postfix state=latest tags: packageonly – name: starting service service: name=postfix state=started [root@workstation ~]# ansible-playbook –syntax-check tags.yaml

playbook: tags.yaml [root@workstation ~]# ansible-playbook -C tags.yaml

PLAY [installing postfix and stopping from […]

Creating role in ansible

Creating role in ansible

Creating a basic role for displaying message of the day

[root@workstation ~]# vim /etc/ansible/roles/motd/main.yml — – name: use motd role playbook hosts: all

roles: – motd

[root@workstation ~]# vim /etc/ansible/roles/motd/defaults/main.yml — system_owner: rmohan [root@workstation ~]# vim /etc/ansible/roles/motd/tasks/main.yml — – name: deliver motd file template: src: templates/motd.j2 dest: /etc/motd owner: root group: […]

Including variables in Ansible

Including variables in Ansible

===================================== [root@ansible1 ~]$ mkdir nginx ===================================== [root@ansible1 ~]$ cd nginx [root@ansible1 nginx]$ mkdir tasks vars

===================================== [root@ansible1 nginx]$ touch tasks/environment.yml ===================================== [root@ansible1 nginx]$ touch vars/variables.yml ===================================== [root@ansible1 ~]$ tree nginx nginx |– nginx.yml |– tasks | `– environment.yml `– vars `– variables.yml ===================================== [root@ansible1 nginx]$ vim tasks/environment.yml — – name: install […]

Continuous Delivery Using Docker And Ansible

Continuous Delivery Using Docker And Ansible

Continuous Delivery Release Often Release Faster Great Reliable

Continuous Delivery workflow/pipeline

With which we can Test,Build,Release,& Deploy a simple application.

Application will be of any technology ex:python based.

The work flow will be Based upon using docker & docker-compose which is a emerging technology. With a goal to release […]