Saturday, 13 July 2019

Ansible playbook for VLAN Creation on cisco switch




---
- hosts: sw
  connection: network_cli
  tasks:
   - name: creating vlan
     ios_vlan:
               authorize: yes
               provider:
                username: cisco
                        password: cisco123
                        host: 172.22.110.201
               vlan_id: 20
               name: testvlan1
               state: present










Ansible playbook for User Creation on cisco switch



---
- hosts: sw
  connection: network_cli
  tasks:
   - name: creating user
     ios_config:
               provider:
                username: cisco
                        password: cisco123
                        host:  172.22.110.201
               lines:
        - username srini privilege 1 password secret456
        - line console 0
        - login local
        - end      

Ansible playbook for Banner Creation on cisco switch




---
- hosts: sw
  connection: network_cli
  tasks:
   - name: install banner
     ios_banner:
        banner: motd
        text: |
        unauthorized access is prohibited
        state: present     

Wednesday, 10 July 2019

Ansible playbook accessing variables from var file



---
- hosts: raghu
  vars_files:
      - firstplaybookvars.yml
  tasks:
      - name: Create file
        file:
            path: "{{ path }}"
            state: "{{ state }}"
        notify:
           - restart apache

  handlers:
      - name: restart apache
        service: name=httpd state=started

---
path: /tmp/raghu
state: touch

Ansible playbook with notify and handlers example


---
- hosts: raghu
  vars:
      path: /tmp/raghu
      state: touch
  tasks:
      - name: Create file
        file:
            path: "{{ path }}"
            state: "{{ state }}"
        notify:
           - restart apache

  handlers:
      - name: restart apache
        service: name=httpd state=started

Ansible playbook loop with condition example



  tasks:
      - name: Create file
        file:
            path: "{{ item.path }}"
            state: "{{ item.state }}"
        loop:
            - { path: '/tmp/ragx' , state: 'touch' }
        when: item.path == '/tmp/raghu'

Ansible playbook loop example



  tasks:
      - name: Create file
        file:
            path: "{{ item.path }}"
            state: "{{ item.state }}"
        loop:
            - { path: '/tmp/raghu' , state: 'touch' }
            - { path: '/opt/raghu' , state: 'touch' }

Git

1 git add ↳ It lets you add changes from the working directory into the staging area 2 git commit ↳ It lets you save a snapshot of currently...