Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devops-school/39243de4e9f23d9687b3ecfeeecaf3d0 to your computer and use it in GitHub Desktop.
Save devops-school/39243de4e9f23d9687b3ecfeeecaf3d0 to your computer and use it in GitHub Desktop.
hp-ansible-classroom-adhoc-june-2019-batch1
@Ahamed-sultan
Copy link


  • name: create a directory and file and append content"
    hosts: deploy
    tasks:
    • name: create directory
      win_file: path=C:\hp\Sultan state=directory
    • name: create a file
      win_file: path=C:\hp\Sultan\index.html state=touch
    • name: adding content to the file
      win_lineinfile: path=C:\hp\Sultan\index.html line='

      Operating system is Red-hat

      '
      when: ansible_facts['os_family'] == "RedHat"
      ...

@neetesh80
Copy link

Lab4 - Windows

---
-  name: Create a file on windows server server
   hosts: windows
   tasks:
     - name: Create a dir
       win_file:
         path: C:\hp\neetesh
         state: directory
     - name: Create a file
       win_file:
         path: C:\hp\neetesh\index.html
         state: touch
     - name: push contents to the file
       win_copy:
         src: /home/tester/index.html
         dest: C:\hp\neetesh\index.html

@neetesh80
Copy link

Lab5- Conditonals

---
-  name: Gather facts for Redhat and windows
   hosts: mix
   tasks:
     - name: Gather windows facts
       win_copy:
         src: /home/tester/index.html
         dest: C:\hp\neetesh\index.html
       when: ansible_distribution == "window"

     - name: Get the linux facts
       lineinfile: dest=/var/www/html/index.html line='<html> <h1> This is Redhat machine </h1>  </html>'
       when: ansible_os_family == "RedHat"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment