2016-09-16 6 views
0

以下の.shコードがあり、これをAnsibleタスクに変換する必要があります。Perlスクリプトを使用してAnuchを呼び出す

#!/bin/sh 
echo "Installing Sonar" 
SONAR_HOME=/tui/hybris/sonar 
if [ ! -d "$SONAR_HOME" ]; then 
mkdir -p $SONAR_HOME 
fi 
cd $SONAR_HOME 
wget https://s3-eu-west-1.amazonaws.com/tuiuk/source/sonarqube/sonarqube-5.4.zip 
unzip sonarqube-5.4.zip 
echo "Modifying Sonar config file" 
cd sonarqube-5.4/conf 
perl -p -i -e 's/#sonar.jdbc.username=/sonar.jdbc.username=sonar/g' sonar.properties 
perl -p -i -e 's/#sonar.jdbc.password=/sonar.jdbc.password=sonar/g' sonar.properties 
perl -p -i -e 's/#sonar.jdbc.url=jdbc:mysql/sonar.jdbc.url=jdbc:mysql/g' sonar.properties 
cd $SONAR_HOME 
echo "downloading and copying plugins" 
wget https://s3-eu-west-1.amazonaws.com/tuiuk/source/sonarqube/sonarqube5.4_plugins.zip 
unzip sonarqube5.4_plugins.zip 
cp plugins/* sonarqube-5.4/extensions/plugins/ 
cd sonarqube-5.4/bin/linux-x86-64 
echo "Starting Sonar" 
./sonar.sh start 

以下は私の仕事です。私はperlスクリプトを実行する必要があります。あなたの誰かが私の手伝ってくれましたか?

- hosts: docker_test 
    tasks: 
    - name: Creates directory 
    file: path=/tui/hybris/sonar state=directory mode=0777 
    sudo: yes 

    - name: Installing Sonar 
    get_url: 
     url: "https://s3-eu-west-1.amazonaws.com/tuiuk/source/sonarqube/sonarqube-5.4.zip" 
     dest: "/tui/hybris/sonar/sonarqube-5.4.zip" 
    register: get_solr 

    - debug: 
     msg: "solr was downloaded" 
    when: get_solr|changed 

    - name: Unzip SonarQube 
    unarchive: src=/tui/hybris/sonar/sonarqube-5.4.zip dest=/tui/hybris/sonar copy=no 

答えて

2

私はあなたが、ここではPerlを必要とします(すべてのオカレンスを変更する必要がある場合)またはreplaceモジュール(あなたは、単一のファイルの行を変更する必要がある場合)regexオプションでlineinfileを使用していない賭け。

0

だけcommandshell -moduleでPerlを呼び出す:

- task: Modifying Sonar config file shell: cd sonarqube-5.4/conf && perl -p -i -e ...

関連する問題