您好,欢迎来到12图资源库!分享精神,快乐你我!我们只是素材的搬运工!!
  • 首 页
  • 当前位置:首页 > 开发 > WEB开发 >
    Ansible剧本的6个排查技巧(2)
    时间:2021-08-07 12:13 来源:网络整理 作者:网络 浏览:收藏 挑错 推荐 打印

      - name: Make sure that we have the right type of content before proceeding 

        assert: 

          that:  

          - "var01 is defined" 

          - "(var01 | type_debug) == 'int' " 

          - "param01 is defined " 

          - "(param01 | type_debug) == 'int' " 

    假设我从命令行运转剧本,不提供额外变量:

    > ansible-playbook xassert.yml 

    PLAY [Assert examples]  

    *************************************************************************** 

    TASK [debug]  

    *************************************************************************** 

    ok: [node1] => { 

        "msg""Parameter 01 is AnsibleUndefined" 

    TASK [Make sure that we have the right type of content before proceeding] *************************************************************************** 

    fatal: [node1]: FAILED! => { 

        "assertion""param01 is defined "

        "changed"false

        "evaluated_to"false

        "msg""Assertion failed" 

    PLAY RECAP  

    *************************************************************************** 

    node1 : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0   

    假设我从命令行运转剧本,运用额外变量:

    > ansible-playbook xassert.yml -e "param01=99" 

    PLAY [Assert examples]  

    *************************************************************************** 

    TASK [debug]  

    *************************************************************************** 

    ok: [node1] => { 

        "msg""Parameter 01 is str" 

    TASK [Make sure that we have the right type of content before proceeding] *************************************************************************** 

    fatal: [node1]: FAILED! => { 

        "assertion""(param01 | type_debug) == 'int' "

        "changed"false

        "evaluated_to"false

        "msg""Assertion failed" 

    PLAY RECAP  

    (责任编辑:admin)