From 8a754e0858d922e955e71b253c139e071ecec432 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 18:04:21 +0200 Subject: Adding upstream version 2.14.3. Signed-off-by: Daniel Baumann --- test/integration/targets/raw/aliases | 2 + test/integration/targets/raw/meta/main.yml | 3 + test/integration/targets/raw/runme.sh | 6 ++ test/integration/targets/raw/runme.yml | 4 ++ test/integration/targets/raw/tasks/main.yml | 107 ++++++++++++++++++++++++++++ 5 files changed, 122 insertions(+) create mode 100644 test/integration/targets/raw/aliases create mode 100644 test/integration/targets/raw/meta/main.yml create mode 100755 test/integration/targets/raw/runme.sh create mode 100644 test/integration/targets/raw/runme.yml create mode 100644 test/integration/targets/raw/tasks/main.yml (limited to 'test/integration/targets/raw') 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 + +# 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 . + +- 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" -- cgit v1.2.3