Skip to content

Ansible Playbook

- hosts: remotehost #  host to execute the task
  tasks:
    - shell: echo Hello World > /tmp/hello.txt # task as a shell script
    - debug:
        msg: "{{ MSG }}" # Log message out
- hosts: webserver
  tasks:
    - name: Transfer template to web server
      template:
        src: table.j2
        dest: /var/www/html/index.php
  • Run playbook
ansible-playbook -i "hosts-file" "playbook-file"
ansible-playbook -i "./hosts" "./playbook.yaml" -e "PEOPLE_AGE=25" # -e for parameters