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

 

上一篇:ansible管理大项目之包含和导入文件


下一篇:DevOps:5大工具