summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/raw
diff options
context:
space:
mode:
Diffstat (limited to 'test/integration/targets/raw')
-rw-r--r--test/integration/targets/raw/aliases2
-rw-r--r--test/integration/targets/raw/meta/main.yml3
-rwxr-xr-xtest/integration/targets/raw/runme.sh6
-rw-r--r--test/integration/targets/raw/runme.yml4
-rw-r--r--test/integration/targets/raw/tasks/main.yml107
5 files changed, 122 insertions, 0 deletions
diff --git a/test/integration/targets/raw/aliases b/test/integration/targets/raw/aliases
new file mode 100644
index 0000000..f5bd1a5
--- /dev/null
+++ b/test/integration/targets/raw/aliases
@@ -0,0 +1,2 @@
+shippable/posix/group1
+needs/target/setup_remote_tmp_dir
diff --git a/test/integration/targets/raw/meta/main.yml b/test/integration/targets/raw/meta/main.yml
new file mode 100644
index 0000000..cb6005d
--- /dev/null
+++ b/test/integration/targets/raw/meta/main.yml
@@ -0,0 +1,3 @@
+dependencies:
+ - prepare_tests
+ - setup_remote_tmp_dir
diff --git a/test/integration/targets/raw/runme.sh b/test/integration/targets/raw/runme.sh
new file mode 100755
index 0000000..2627599
--- /dev/null
+++ b/test/integration/targets/raw/runme.sh
@@ -0,0 +1,6 @@
+#!/usr/bin/env bash
+
+set -ux
+export ANSIBLE_BECOME_ALLOW_SAME_USER=1
+export ANSIBLE_ROLES_PATH=../
+ansible-playbook -i ../../inventory runme.yml -v "$@"
diff --git a/test/integration/targets/raw/runme.yml b/test/integration/targets/raw/runme.yml
new file mode 100644
index 0000000..ea865bc
--- /dev/null
+++ b/test/integration/targets/raw/runme.yml
@@ -0,0 +1,4 @@
+- hosts: testhost
+ gather_facts: no
+ roles:
+ - { role: raw }
diff --git a/test/integration/targets/raw/tasks/main.yml b/test/integration/targets/raw/tasks/main.yml
new file mode 100644
index 0000000..ce03c72
--- /dev/null
+++ b/test/integration/targets/raw/tasks/main.yml
@@ -0,0 +1,107 @@
+# Test code for the raw module.
+# (c) 2017, James Tanner <tanner.jc@gmail.com>
+
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+
+- set_fact: remote_tmp_dir_test={{remote_tmp_dir}}/test_command_raw
+
+- name: make sure our testing sub-directory does not exist
+ file: path="{{ remote_tmp_dir_test }}" state=absent
+
+- name: create our testing sub-directory
+ file: path="{{ remote_tmp_dir_test }}" state=directory
+
+##
+## raw
+##
+
+- name: touch a file
+ raw: "touch {{remote_tmp_dir_test | expanduser}}/test.txt"
+ register: raw_result0
+- debug: var=raw_result0
+- stat:
+ path: "{{remote_tmp_dir_test | expanduser}}/test.txt"
+ register: raw_result0_stat
+- debug: var=raw_result0_stat
+- name: ensure proper results
+ assert:
+ that:
+ - 'raw_result0.changed is defined'
+ - 'raw_result0.rc is defined'
+ - 'raw_result0.stderr is defined'
+ - 'raw_result0.stdout is defined'
+ - 'raw_result0.stdout_lines is defined'
+ - 'raw_result0.rc == 0'
+ - 'raw_result0_stat.stat.size == 0'
+
+- name: run a piped command
+ raw: "echo 'foo,bar,baz' | cut -d\\, -f2 | tr 'b' 'c'"
+ register: raw_result1
+- debug: var=raw_result1
+- name: ensure proper results
+ assert:
+ that:
+ - 'raw_result1.changed is defined'
+ - 'raw_result1.rc is defined'
+ - 'raw_result1.stderr is defined'
+ - 'raw_result1.stdout is defined'
+ - 'raw_result1.stdout_lines is defined'
+ - 'raw_result1.rc == 0'
+ - 'raw_result1.stdout_lines == ["car"]'
+
+- name: get the path to bash
+ shell: which bash
+ register: bash_path
+- name: run exmample non-posix command with bash
+ raw: "echo 'foobar' > {{remote_tmp_dir_test | expanduser}}/test.txt ; cat < {{remote_tmp_dir_test | expanduser}}/test.txt"
+ args:
+ executable: "{{ bash_path.stdout }}"
+ register: raw_result2
+- debug: var=raw_result2
+- name: ensure proper results
+ assert:
+ that:
+ - 'raw_result2.changed is defined'
+ - 'raw_result2.rc is defined'
+ - 'raw_result2.stderr is defined'
+ - 'raw_result2.stdout is defined'
+ - 'raw_result2.stdout_lines is defined'
+ - 'raw_result2.rc == 0'
+ - 'raw_result2.stdout_lines == ["foobar"]'
+# the following five tests added to test https://github.com/ansible/ansible/pull/68315
+- name: get the path to sh
+ shell: which sh
+ register: sh_path
+- name: use sh
+ raw: echo $0
+ args:
+ executable: "{{ sh_path.stdout }}"
+ become: true
+ become_method: su
+ register: sh_output
+- name: assert sh
+ assert:
+ that: "(sh_output.stdout | trim) == sh_path.stdout"
+- name: use bash
+ raw: echo $0
+ args:
+ executable: "{{ bash_path.stdout }}"
+ become: true
+ become_method: su
+ register: bash_output
+- name: assert bash
+ assert:
+ that: "(bash_output.stdout | trim) == bash_path.stdout"