Ansible Notes – Aug Batch Online – Notes – Day -5

Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll Now
Vars
Faq
Cond
Looping
----------------
Templates
	
Handlers
Roles


---
- name: Update web servers
  hosts: localhost
  vars:
    myname: "Rajeshkumar"
    age: "18"
    packagename: "apache2"
    servicename: "apache2"

  tasks:
  - name: Install Apache in ubuntu
    ansible.builtin.apt:
      name: "{{ packagename }}"
      state: latest
  - name: Copy index.html
    ansible.builtin.copy:
      src: index.html
      dest: /var/www/html/index.html
  - name: Starting a Apache Server
    ansible.builtin.service:
      name: "{{ servicename }}"
      state: started
  - name: Print return information from the previous task
    ansible.builtin.debug:
      var: myname
  - name: Template index.html
    template:
      src: index.html.j2
      dest: /var/www/html/index-template.html











---
- name: Update web servers
  hosts: localhost
  vars:
    myname: "Rajesh Kumar"
    port: 81

  tasks:
  - name: Install Apache in Ubuntu
    ansible.builtin.apt:
      name: apache2
      state: latest
  - name: Copy index.html
    ansible.builtin.copy:
      src: index.html
      dest: /var/www/html/index.html
  - name: Template for httpd.conf
    template:
      src: ports.conf.j2
      dest: /etc/apache2/ports.conf
    notify:
      - ReStarting a Apache Server
  - name: Starting a Apache Server
    ansible.builtin.service:
      name: apache2
      state: started

  handlers:
  - name: ReStarting a Apache Server
    ansible.builtin.service:
      name: apache2
      state: restarted
=============================================================


Roles
=================================
diretory layout
	vars
	tasks
	template
	files
	handlers



site.yaml

---
- name: Update web servers
  hosts: localhost

  roles:
    - web
    - geerlingguy.java

==================================
Tower
---------------------------





Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x