Translate

2014年12月19日金曜日

SELINUX=enforcingのままでJenkinsを動かす

CentOS 7 LTS 環境に以下の手順でJenkinsサーバをインストールした。



yum -y updape
yum -y install httpd java wget
wget --retr-symlinks -O /etc/yum.repos.d/jenkins.repo \
 http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo
yum -y remove wget
rpm --import http://pkg.jenkins-ci.org/redhat-stable/jenkins-ci.org.key
yum -y install jenkins
vi /etc/sysconfig/jenkins
 JENKINS_LISTEN_ADDRESS="127.0.0.1"
 JENKINS_ARGS="--prefix=/jenkins"
vi /etc/httpd/conf.d/jenkins.conf
 ProxyPass         /jenkins  http://127.0.0.1:8080/jenkins nocanon
 ProxyPassReverse  /jenkins  http://127.0.0.1:8080/jenkins
 ProxyRequests     Off
 AllowEncodedSlashes NoDecode
 <Proxy http://127.0.0.1:8080/jenkins*>
     Order deny,allow
     Allow from all
 </Proxy>
systemctl enable jenkins.service
systemctl enable httpd.service

SELINUX=enforcingのままで動かしたかったので

chcon -R -t httpd_sys_content_t /var/lib/jenkins/
chcon -R -t httpd_sys_rw_content_t /var/lib/jenkins/
firewall-cmd --permanent --zone=public --add-service=http

を実行して再起動し、http://server/jenkins をブラウザから
開こうとしたのだけど..

なぜか開かない..

/var/log/auth/auth.log を調べてみると


type=AVC msg=audit(1418962121.878:241): avc:  denied  { name_connect } for  pid=2129 comm="httpd" dest=8080 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:http_cache_port_t:s0 tclass=tcp_socket

というのを見つけた。

どうもhttpdから127.0.0.1:8080へ通信しようとしてるのを
SELINUXが弾いているようだ..

このため

setsebool -P httpd_can_network_connect true

を実行してブラウザからひらいてみたら..

..うまくいった..

SELINUX=disabledにするのは簡単だけど
パブリックIaaSとかに自動で仮想マシン作るChefとかかこうとなると
やはりenforcingで動かしたい..

ためしていないが、
yumhttpdtomcatをインストールして
jenkins.war$TOMCAT_HOME/webappsデプロイしていれば
たぶんさっくりうごくんじゃないかな
yumsetseboolしてくれているのだろう..

めんどくさいぞSELINUX..

0 件のコメント:

既存アプリケーションをK8s上でコンテナ化して動かす場合の設計注意事項メモ

既存アプリをK8sなどのコンテナにして動かすには、どこを注意すればいいか..ちょっと調べたときの注意事項をメモにした。   1. The Twelve Factors (日本語訳からの転記) コードベース   バージョン管理されている1つのコードベースと複数のデプロイ 依存関係 ...