github.com/masahide/goansible@v0.0.0-20160116054156-01eac649e9f2/test/playbook1.yml (about)

     1  # extremely simple test of the most basic of playbook engine/functions
     2  ---
     3  - include: incplaybook.yml sub1=from_include
     4    vars:
     5      sub2: "from include"
     6  
     7  - hosts: all
     8    connection: local
     9  
    10  # the 'weasels' string should show up in the output
    11  
    12    vars:
    13      answer: "Wuh, I think so"
    14      port: 5150
    15  
    16  # we should have import events for common_vars and CentOS.yml (if run on CentOS)
    17  # sorry, tests are a bit platform specific just for now
    18  
    19    vars_files:
    20      - common_vars.yml
    21      - [ '{{facter_operatingsystem.yml}}', 'default_os.yml' ]
    22  
    23    tasks:
    24  
    25    - name: test basic success command
    26      action: command true
    27  
    28    - name: test basic success command 2
    29      action: command true
    30  
    31    - name: test keyed command syntax
    32      command: true
    33  
    34    - name: test basic shell, plus two ways to dereference a variable
    35      action: shell echo {{port}}
    36  
    37    - name: test vars_files imports
    38      action: shell echo {{duck}} {{cow}} {{testing}}
    39      notify:
    40      - on change 1
    41  
    42  # in the command below, the test file should contain a valid template
    43  # and trigger the change handler
    44  
    45    - name: test copy
    46      action: copy src=test/sample dest=/tmp/ansible_test_data_copy.out
    47      notify:
    48      - on change 1
    49  
    50    - name: test copy 2
    51      copy:
    52        src: test/sample
    53        dest: /tmp/goansible_test_data_copy2.out
    54  
    55    - name: test dollar expansion
    56      action: shell echo {{ duck }}
    57  
    58    - name: test outer vars
    59      action: shell echo $(or :user "unknown")
    60  # there should be various poll events within the range
    61  
    62    - name: async poll test
    63      action: shell sleep 5
    64      async: 10
    65      poll: 3
    66  
    67  # the following command should be skipped
    68  
    69    - name: this should be skipped
    70      action: shell echo 'if you see this, this is wrong'
    71      when: $(== 2 3)
    72  
    73  # this should run
    74    - name: this should be run
    75      action: shell echo 'if you see this, everything is good'
    76      when: $(== 3 3)
    77      notify:
    78      - on change 2
    79  
    80  # this should not run
    81    - name: this should be not run variables
    82      action: shell echo 'if you see this, you can matching variables is busted'
    83      when: $(== duck "xxx")
    84  
    85  # this should run
    86    - name: this should be run variables
    87      action: shell echo 'if you see this, you can match variables'
    88      when: $(== duck "quack")
    89      notify:
    90      - on change 2
    91  
    92    handlers:
    93  
    94  # in the above test example, this should fire ONCE (at the end)
    95    - name: on change 1
    96      action: shell echo 'this should fire once'
    97  
    98  # in the above test example, this should fire ONCE (at the end)
    99  
   100    - name: on change 2
   101      action: shell echo 'this should fire once also'
   102  
   103  # in the above test example, this should NOT FIRE
   104  
   105    - name: on change 3
   106      action: shell echo 'if you see this, this is wrong'