• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

ansible-playbook: command not found

by admin

Using ad-hoc commands is an imperative method and is no better than using the SSH client to execute commands remotely.

You need two components to make it into real, imperative orchestration: a playbook and modules. The playbook is the basis for your system’s deployment, configuration, and maintenance. It can orchestrate everything, even between hosts! A playbook is there to describe the state you want to reach. Playbooks are written in the YAML language and can be executed with the ansible-playbook command:

$ ansible-playbook [filename]

The second component is the module. The best way to describe a module is: the task to be executed to reach the desired state. They are also known as task plugins or library plugins.

If you encounter the below error while running the ansible-playbook command:

ansible-playbook: command not found

you may try installing the below package as per your choice of distribution.

Distribution Command
OS X brew install ansible
Debian apt-get install ansible
Ubuntu apt-get install ansible
Alpine apk add ansible
Arch Linux pacman -S ansible
Kali Linux apt-get install ansible
CentOS yum install ansible
Fedora dnf install ansible
Raspbian apt-get install ansible

ansible-playbook Command Examples

1. Run tasks in playbook:

$ ansible-playbook playbook

2. Run tasks in playbook with custom host inventory:

$ ansible-playbook playbook -i inventory_file

3. Run tasks in playbook with extra variables defined via the command-line:

$ ansible-playbook playbook -e "variable1=value1 variable2=value2"

4. Run tasks in playbook with extra variables defined in a JSON file:

$ ansible-playbook playbook -e "@variables.json"

5. Run tasks in playbook for the given tags:

$ ansible-playbook playbook --tags tag1,tag2

6. Run tasks in a playbook starting at a specific task:

$ ansible-playbook playbook --start-at task_name

7. To check the Ansible syntax, use:

$ ansible-playbook --syntax-check Ansible/example1.yaml

Filed Under: Ansible, DevOps, Linux

Some more articles you might also be interested in …

  1. How to control resource (cgroup) with systemd for user process group in CentOS/RHEL 7
  2. bmon Command Examples in Linux
  3. btrfs inspect-internal Command Examples in Linux
  4. CentOS / RHEL : How to log all LVM commands
  5. mdadm Command Examples in Linux
  6. CentOS / RHEL 5 : How to password-protect single user mode
  7. How to Create yum Repository in CentOS/RHEL
  8. LVM and multipathing – sample LVM filter strings
  9. How to configure VNC Server on Oracle Linux 6
  10. dnsrecon Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • powertop Command Examples in Linux
  • powertop: command not found
  • powerstat: command not found
  • powerstat Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright