Difference between revisions of "IT-SDK-Ansible"

From wiki.samerhijazi.net
Jump to navigation Jump to search
(Inventory)
(Playbook)
Line 24: Line 24:
 
- name: this playbook will install httpd  ## Name of the Play
 
- name: this playbook will install httpd  ## Name of the Play
 
   hosts: web                              ## In which Node shall the play done
 
   hosts: web                              ## In which Node shall the play done
 +
  vars:                                  ## Definition von Variables
 +
    pkgname: httpd
 
   tasks:                                  ## Tasks in this play
 
   tasks:                                  ## Tasks in this play
 
     - name: Install latest of Apache      ## Name of the Task
 
     - name: Install latest of Apache      ## Name of the Task
Line 29: Line 31:
 
       become_user: weblogic              ## Exceute this task as "sudo -u weblogic dnf install httpd"
 
       become_user: weblogic              ## Exceute this task as "sudo -u weblogic dnf install httpd"
 
       dnf:                                ## Name of the Modul used (etc. command, apt, user, service )
 
       dnf:                                ## Name of the Modul used (etc. command, apt, user, service )
         name: httpd                      ## Parameter used form modul
+
         name: {{ pkgname }}              ## Parameter used form modul
 
         state: latest                    ## Parameter used form modul
 
         state: latest                    ## Parameter used form modul
 
</pre>
 
</pre>

Revision as of 14:37, 31 July 2021

Ref.

Notes

  • Ansible: playbooks, roles, variables, basic modules

Commands

ansible-playbook playbook.yml ## execute the playbook

Inventory

  • lists which hosts will receive commands from the control host
  • hosts, or group
  • location for the inventory file: /etc/ansible/hosts
ansible all --list-hosts

Playbook

# Play 1
---
- name: this playbook will install httpd  ## Name of the Play
  hosts: web                              ## In which Node shall the play done
  vars:                                   ## Definition von Variables
    pkgname: httpd
  tasks:                                  ## Tasks in this play
    - name: Install latest of Apache      ## Name of the Task
      become: ture                        ## Execute this Task as "sudo dnf install httpd"
      become_user: weblogic               ## Exceute this task as "sudo -u weblogic dnf install httpd"
      dnf:                                ## Name of the Modul used (etc. command, apt, user, service )
        name: {{ pkgname }}               ## Parameter used form modul
        state: latest                     ## Parameter used form modul