Signed-off-by: Wang Chenglong 18509160991@163.com --- tests/ansible_test | 84 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100755 tests/ansible_test
diff --git a/tests/ansible_test b/tests/ansible_test new file mode 100755 index 000000000..36164bcae --- /dev/null +++ b/tests/ansible_test @@ -0,0 +1,84 @@ +#!/bin/bash +# - ansible_repo + +. $LKP_SRC/lib/debug.sh + +check_vars() +{ + ansible_host=localhost + echo $ansible_host + + [ -n "$ansible_repo" ] || die "ansible_repo is empty" + benchmark=${ansible_repo##*/} + + ansible_path=/root/.ansible + [ -d "$ansible_path" ] || mkdir -p /root/.ansible +} + +install_ansible() +{ + if [ "$os" == "openeuler" ]; then + yum -y reinstall git + yum -y install python3 + pip3 install ansible + elif [ "$os" == "centos" ]; then + yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm + yum -y reinstall git + yum -y install ansible + elif [ "$os" == "debian" ]; then + apt-get install -y ansible + fi + + command -v ansible > /dev/null && { + ansible localhost -m ping + [ $? -eq 0 ] && { + echo "Ansible is successfully deployed!" + } + } +} + +download_ansible_role() +{ + + ansible_roles_path=$ansible_path/roles + [ -d $ansible_roles_path ] || mkdir -p $ansible_roles_path + cd $ansible_roles_path + git clone git://github.com/$ansible_repo.git || exit 1 + # git clone git://$GIT_SERVER/$ansible_repo.git || exit + # ansible-galaxy install $username.$rolename + if [ $? -eq 0 ]; then + echo "$benchmark is successfully installed" + else + echo "Please check whether your ansible_repo is correct!" + fi +} + +ansible_playbook_run() +{ + cat <<-EOF > "$ansible_path"/site.yml + - hosts: $ansible_host + roles: + - role: $benchmark + EOF + [ $? -eq 0 ] && { + echo "Playbook has been generated!" + } + + ansible-playbook "$ansible_path"/site.yml + + if [ $? -eq 0 ]; then + echo "Your playbook is running successfully!" + else + echo "Your playbook failed to run!" && exit 1 + fi +} + +main() +{ + check_vars + install_ansible + download_ansible_role + ansible_playbook_run +} + +main
On Thu, Mar 11, 2021 at 02:43:13PM +0800, Wang Chenglong wrote:
Signed-off-by: Wang Chenglong 18509160991@163.com
tests/ansible_test | 84 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100755 tests/ansible_test
diff --git a/tests/ansible_test b/tests/ansible_test new file mode 100755 index 000000000..36164bcae --- /dev/null +++ b/tests/ansible_test @@ -0,0 +1,84 @@ +#!/bin/bash +# - ansible_repo
+. $LKP_SRC/lib/debug.sh
+check_vars() +{
- ansible_host=localhost
- echo $ansible_host
- [ -n "$ansible_repo" ] || die "ansible_repo is empty"
- benchmark=${ansible_repo##*/}
- ansible_path=/root/.ansible
- [ -d "$ansible_path" ] || mkdir -p /root/.ansible
+}
+install_ansible() +{
- if [ "$os" == "openeuler" ]; then
yum -y reinstall git
yum -y install python3
pip3 install ansible
- elif [ "$os" == "centos" ]; then
yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum -y reinstall git
yum -y install ansible
- elif [ "$os" == "debian" ]; then
apt-get install -y ansible
- fi
- command -v ansible > /dev/null && {
ansible localhost -m ping
[ $? -eq 0 ] && {
echo "Ansible is successfully deployed!"
}
- }
+}
+download_ansible_role() +{
redundant blank line.
- ansible_roles_path=$ansible_path/roles
- [ -d $ansible_roles_path ] || mkdir -p $ansible_roles_path
- cd $ansible_roles_path
- git clone git://github.com/$ansible_repo.git || exit 1
- # git clone git://$GIT_SERVER/$ansible_repo.git || exit
unused annonation, the same as below.
-------- Thanks, Xijian
On Thu, Mar 11, 2021 at 03:07:11PM +0800, Xu Xijian wrote:
On Thu, Mar 11, 2021 at 02:43:13PM +0800, Wang Chenglong wrote:
Signed-off-by: Wang Chenglong 18509160991@163.com
tests/ansible_test | 84 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100755 tests/ansible_test
diff --git a/tests/ansible_test b/tests/ansible_test new file mode 100755 index 000000000..36164bcae --- /dev/null +++ b/tests/ansible_test @@ -0,0 +1,84 @@ +#!/bin/bash +# - ansible_repo
+. $LKP_SRC/lib/debug.sh
+check_vars() +{
- ansible_host=localhost
- echo $ansible_host
- [ -n "$ansible_repo" ] || die "ansible_repo is empty"
- benchmark=${ansible_repo##*/}
- ansible_path=/root/.ansible
- [ -d "$ansible_path" ] || mkdir -p /root/.ansible
+}
+install_ansible() +{
- if [ "$os" == "openeuler" ]; then
yum -y reinstall git
yum -y install python3
pip3 install ansible
- elif [ "$os" == "centos" ]; then
yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum -y reinstall git
yum -y install ansible
- elif [ "$os" == "debian" ]; then
apt-get install -y ansible
- fi
- command -v ansible > /dev/null && {
ansible localhost -m ping
[ $? -eq 0 ] && {
echo "Ansible is successfully deployed!"
}
- }
+}
+download_ansible_role() +{
redundant blank line.
ok.
- ansible_roles_path=$ansible_path/roles
- [ -d $ansible_roles_path ] || mkdir -p $ansible_roles_path
- cd $ansible_roles_path
- git clone git://github.com/$ansible_repo.git || exit 1
- # git clone git://$GIT_SERVER/$ansible_repo.git || exit
unused annonation, the same as below.
Ok. i will delete it.
Thanks, Xijian
+install_ansible() +{
- if [ "$os" == "openeuler" ]; then
yum -y reinstall git
yum -y install python3
pip3 install ansible
- elif [ "$os" == "centos" ]; then
yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum -y reinstall git
yum -y install ansible
- elif [ "$os" == "debian" ]; then
apt-get install -y ansible
- fi
- command -v ansible > /dev/null && {
ansible localhost -m ping
[ $? -eq 0 ] && {
echo "Ansible is successfully deployed!"
No need to show successful message. Instead, please show error message and abort if failed.
Thanks, Fengguang
}
- }
+}
On Thu, Mar 11, 2021 at 03:18:29PM +0800, Wu Fengguang wrote:
+install_ansible() +{
- if [ "$os" == "openeuler" ]; then
yum -y reinstall git
yum -y install python3
pip3 install ansible
- elif [ "$os" == "centos" ]; then
yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum -y reinstall git
yum -y install ansible
- elif [ "$os" == "debian" ]; then
apt-get install -y ansible
- fi
- command -v ansible > /dev/null && {
ansible localhost -m ping
[ $? -eq 0 ] && {
echo "Ansible is successfully deployed!"
No need to show successful message. Instead, please show error message and abort if failed.
Ok. got it.
Thanks, Fengguang
}
- }
+}