Install ansible on Centos 7 / RHEL 7

Install ansible on Centos 7 / RHEL 7

1. Install epel-release package

yum install

2. Installation

2.1 Update the OS
             yum update

2.2 Install the ansible
             yum install ansible

2.3 check ansible version
            ansible –version


PHP unit test using Jenkins and Ansible script


1.1 Create the Jenkins Job

Jenkins -> New Item -> Freestype project – >

Enter the project name


1.2 At the Build section,  “Add build step” ->  Execute shell , enter the ansible-playbook details to be executed

1.3 In the “Post-build Actions” ->  “Add post-build actions” -> “Publish JUnit test result report” -> and set “Test reports XMLs” to the php unit test output xml file

2. Ansible playbook

– hosts: host1
base_dir: /projectdir/
– name: run testrunner
shell: php vendor/bin/phpunit –log-junit results/phpunit/phpunit.xml
chdir: “{{ base_dir }}/api”
register: phpunit_output
ignore_errors: yes

– name: rsync results/phpunit/phpunit.xml file to jenkins
command: rsync -vr root@host1:/project/results /var/lib/jenkins/jobs/Php-test/workspace/
delegate_to: localhost


eg: host1 , host where the php project is located