ansible实践
作者:互联网
1. 单独执行某个role
cat <<EOF >./playbook.yml- hosts: edgenode_grouppre_tasks:- name: set node nameset_fact: node_name={{ ansible_nodename | lower }}- name: create helper variableset_fact:single_node_deployment:true- name: check deployment settingsinclude_tasks: ./oek/tasks/settings_check_ne.yml - name: check deployment settingsforsingle node deployment include_tasks: ./oek/tasks/settings_check_ne_single_node.yml- name: print deployment settingsinclude_tasks: ./oek/tasks/print_vars.yml- hosts: controller_grouppre_tasks:- name: set node nameset_fact: node_name={{ ansible_nodename | lower }}- name: create helper variableset_fact:single_node_deployment:trueEOF# get all hosts and some informationsansible-playbook -vv playbook.yml -i inventory.ini --list-hostsANHOST=controlleransible -i inventory.ini -m ping $ANHOSTansible $ANHOST -i inventory.ini -m import_role -a name=nfdansible $ANHOST -i inventory.ini -m include_role -a name=nfdPREPATH=. [[ $(basename"$PWD") =="x-openness-experience-kits"]] && PREPATH=oek ansible $ANHOST -i inventory.ini -m include_tasks -a file=$PREPATH/roles/nfd/tasks/main.yml
标签:node,tasks,name,实践,ansible,inventory,deployment,yml 来源: https://www.cnblogs.com/shaohef/p/15084252.html