The below example is for a custom piece of software one of my. This Jinja2 expression can evaluate the value. The task is only executed if this Jinja2 expression evaluates to true. The value of the when key is a Jinja2 expression without the curly braces. For the removes option, you need at least Ansible 0.8. We will cover following 3 different kinds of conditional statements in this section. Just as the creates option, there is the removes option. The command you are using will remove that file, so only if the file is there the action should be executed. Open your favorite text editor and create and save a file called ansible-windows.yml in the /ansible-windows-demo directory. The same goes for only executing an action if a file exists. mkdir /ansible-windows-demo cd /ansible-windows-demo. Ansible didn’t do anything to install the latest version of sl, since it was already there. github/ # parseable: true # quiet: true # verbosity: 1 # Mock modules or roles in order to pass ansible-playbook -syntax-check mock_modules : - zuul_return # note the foo.bar is invalid as being neither a module or a collection - fake_namespace.fake_collection.fake_module - fake_namespace.fake_collection.fake_module.fake_submodule mock_roles : - mocked_role - author.role_name # old standalone galaxy role - fake_namespace.fake_collection.fake_role # role within a collection # Enable checking of loop variable prefixes in roles loop_var_prefix : "" # - galaxy: "**/folder/galaxy.yml" # - tasks: "**/tasks/*.yml" # - vars: "**/vars/*.yml" # - meta: "**/meta/main.yml" - yaml : "**/*. Create a folder under your home directory called ansible-windows-demo and change to it. This time only a single change was made - apt package list was updated. cache/ # implicit unless exclude_paths is defined in config. CLI arguments passed to the -exclude # option will be parsed relative to the CWD of execution. excludepaths:-.cache/ implicit unless excludepaths is defined in config-.github/ parseable: true quiet: true verbosity: 1 Mock modules or roles in. Whether to install ( present ), or remove ( absent ) a package. create a playbook test.yml that will install apache2 sqlite3 git. This documentation only covers the minimum intersection of module arguments that all. CLI arguments passed to the -exclude option will be parsed relative to the CWD of execution. only if somefile.j2 does not exist in host01. ansible-lint # exclude_paths included in this file are parsed relative to this file's location # and not relative to the CWD of execution. .ansible-lint excludepaths included in this file are parsed relative to this file's location and not relative to the CWD of execution.