Ansible Variables

From rbachwiki
Revision as of 17:44, 14 July 2022 by Bacchas (talk | contribs)
Jump to navigation Jump to search

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




---
- name: copy file
  hosts: all
  vars:
    srcfile: /home/somefile.txt
  tasks:

  -name: copy file
   copy:
     src: ""{{ srcfile }}""
     dest: /tmp
     owner: wheel
     group: www
     mode: 0644

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