Ansible playbook application details

Basic components of the playbook:

  Hosts: the target host running the specified task;

  remote_user: The user who executes the task on the remote host;

    sudo_user:

  tasks: task list

    module, module parameter;

    Format:

      (1) action:module arguments

      (2) module:arguments

      Note: The shell and command modules are directly followed by the command, not the parameter list of the key=value class;

    (1) When the status of a task is changed after running, it can be notified to the corresponding handlers through "notify";

    (2) Tasks can be tagged with "tags", and then can be called using -t on the ansible-playbook command;

The way to run the playbook:

  (1) Test

    ansible-playbook  --check

      Only detect possible changes, but do not actually perform actions;

    ansible-playbook  --list-hosts

      List hosts running tasks;

  (2) run

 

handlers:

  Tasks, which are triggered under certain conditions;

  Triggered when notifications from other tasks are received;

 

 variables:

  (1) facts: can be called directly;

  (2) Custom variables in the command line of the ansible-playbook command:

     -e VARS, - extra-vars = VARS

  (3) Pass variables through role;

  (4) Host Inventory

    Pass different variables to different hosts;

 

 

 

 

  

 

 

 

 

 

 

 

 

 

 

 

 

 

    

  

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325001108&siteId=291194637