Difference between revisions of "Ansible Variables"

From rbachwiki
Jump to navigation Jump to search
Line 34: Line 34:
         dest: /etc/ansible/playbook
         dest: /etc/ansible/playbook
</pre>
</pre>
=[[Ansible| Ansible Menu]]=
[[Category:Ansible]]

Revision as of 16:19, 14 July 2022

Ansible Variables

 ---
 - name: setup apache ser er
  hosts: localhost
  vars:
    variablename: apache2
  tasks:
    apt:
      name: "{{ variablename }}"
      state: present
   tags: i-apache
 -name: start apache
 service:
   name: "{{ variablename }}"
   state: started
 tags: start_apache2

Get input from user

---
- hosts: localhost
  vars_prompt:

    - name: fname
      prompt: "what is the filename"
      private: no

  tasks:
    - name: copy file
      copy:
        src: ~/{{ fname }}
        dest: /etc/ansible/playbook


Ansible Menu