なので、Create New Projectで既存のディレクトリを指定して開くようにしてみたらうまくいったので、その時のメモ。
1.Create New Projectをクリック
2.PHP Empty Projectを選択して、Nextをクリック
3.Project locationの部分を選択して、読み込みたいディレクトリを選択し、任意のProject nameを入れるてFinishボタンをクリック。このように既存ディレクトリを選択することで、Import Projectと同じ事ができる。
su -l vagrant -c java -jar /usr/lib/jenkins/jenkins.war --httpPort=18080
| コマンドライン・パラメータ | 説明 |
| --javaHome=$JAVA_HOME | JavaやAntが必要なビルドを実行するときに使用する$JAVA_HOMEをJenkinsに渡します。これはJenkinsを起動するJREではありません(Jenkins上で使用するJREを指定します)。デフォルトは、Jenkinsを実行するのに使用したJREです。 |
| --httpPort=$HTTP_PORT | Jenkinsが使用するHTTPプロトコルのポート番号を指定します。デフォルトは8080です。これを使用しない(_HTTPS_を使用)ようにするには、-1を指定します。 |
| --httpListenAddress=$HTTP_HOST | このパラメータで、Jenkinsがリクエストを受け付けるIPアドレスを指定できます。環境変数$HTTP_HOSTが指定されていれば、それを利用します。デフォルトでは 0.0.0.0 です。--- この場合、すべての有効なインタフェース上で(httpPortで指定された)ポートをリスンします。 |
| --httpsPort=$HTTP_PORT | HTTPSプロトコルで使用するポート番号を指定します。 |
| --httpsListenAddress=$HTTPS_HOST | JenkinsがHTTPSプロトコルでリクエストを受け付けるIPアドレスを指定できます。環境変数$HTTPS_HOSTが指定されていれば、それを利用します。 |
| --ajp13Port=$AJP_PORT | 標準のAJP13プロトコルを使う場合、$AJP_PORTRを利用して、Jenkinsがリスンするポートを指定できます。デフォルトは8009です。(_HTTPS_を使用するため) これを使用しないようにするには、-1を指定します。 |
| --ajp13ListenAddress=$AJP_HOST | JenkinsがAJP13プロトコルのリクエストを受け付ける、IPアドレスを指定できます。デフォルトでは 0.0.0.0 です。 --- i.e. この場合、すべての有効なインタフェース上で(ajpPortで指定された) ポートをリスンします。 |
| --argumentsRealm.passwd.$ADMIN_USER=password | ユーザー $ADMIN_USERのパスワードを設定します。Jenkinsのセキュリティが有効化されている場合、Jenkinsやプロジェクトを設定するために、$ADMIN_USERでログインする必要があります。注意: 管理者権限を持つユーザーも指定しなければなりません。(以下を参照してください) |
| --argumentsRealm.roles.$ADMIN_USER=admin | $ADMIN_USERを管理者として設定し、Jenkinsのセキュリティが有効化されていれば、Jenkinsを設定できるようにします。詳しくはJenkinsのセキュリティを参照してください。 |
$ vagrant resume
==> default: VM not created. Moving on...
$ vagrant status
Current machine states:
default not created (virtualbox)
The environment has not yet been created. Run `vagrant up` to
create the environment. If a machine is not created, only the
default provider will be shown. So if a provider is not listed,
then the machine is not created for that environment.
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'centos6.4'...
==> default: Matching MAC address for NAT networking...
A VirtualBox machine with the name 'centos' already exists.
Please use another name or delete the machine with the existing
name, and try again.
/path/to/vagrant_home/.vagrant/machines/default/virtualbox/id
$ ls -la .vagrant/machines/default/virtualbox/
合計 4
drwxr-xr-x+ 1 kusagaya-naoki Domain Users 0 5月 26 15:31 .
drwxr-xr-x+ 1 kusagaya-naoki Domain Users 0 5月 18 13:11 ..
cd C:\Program Files\Oracle\VirtualBox
C:\Program Files\Oracle\VirtualBox> VBoxManage.exe list vms
"vm_name" {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}
$ vi /path/to/vagrant_home/.vagrant/machines/default/virtualbox/id
XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
$ vagrant status
Current machine states:
default saved (virtualbox)
To resume this VM, simply run `vagrant up`.
$ vagrant resume
==> default: Resuming suspended VM...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2223
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection refused. Retrying...
==> default: Machine booted and ready!
$ vi files/file.conf
{{ project_name }}
$ vi playbook.yml
- template: src=files/file.conf dest=/etc/file.conf mode=0644
ansible-playbook playbook.yml --extra-vars "project_name=test-project"
$ vi /etc/file.conf
test-project
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==> default: Forwarding ports...
default: 22 => 2222 (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
default: /vagrant => C:/cygwin64/home/XXXXXXXXX/XXXXXXXXX/XXXXXXXXX-1
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: to force provisioning. Provisioners marked to run always will still run.
$ vagrant suspend
==> default: Saving VM state and suspending execution...
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==> default: Forwarding ports...
default: 22 => 2222 (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Remote connection disconnect. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
default: /vagrant => C:/cygwin64/home/XXXXXXXXX/XXXXXXXXX/XXXXXXXXX-2
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: to force provisioning. Provisioners marked to run always will still run.
$ vagrant suspend
==> default: Saving VM state and suspending execution...
$ vagrant resume
==> default: Resuming suspended VM...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection refused. Retrying...
==> default: Machine booted and ready!
$ vagrant resume
Vagrant cannot forward the specified ports on this VM, since they
would collide with some other application that is already listening
on these ports. The forwarded port to 2222 is already in use
on the host machine.
To fix this, modify your current projects Vagrantfile to use another
port. Example, where '1234' would be replaced by a unique host port:
config.vm.network :forwarded_port, guest: 22, host: 1234
Sometimes, Vagrant will attempt to auto-correct this for you. In this
case, Vagrant was unable to. This is usually because the guest machine
is in a state which doesn't allow modifying port forwarding.
config.vm.network "forwarded_port", id: "ssh", guest: 22, host: 2223
# config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.network "forwarded_port", id: "ssh", guest: 22, host: 2223 ← この部分を追記
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==> default: Forwarding ports...
default: 22 => 2223 (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2223
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
default: /vagrant => C:/cygwin64/home/XXXXXXXXX/XXXXXXXXX/XXXXXXXXX-2
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: to force provisioning. Provisioners marked to run always will still run.
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==> default: Forwarding ports...
default: 22 => 2222 (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
default: /vagrant => C:/cygwin64/home/kusagaya-naoki/VirtualBoxMachines/jenkins-laravel
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: to force provisioning. Provisioners marked to run always will still run.
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
==> default: Fixed port collision for 22 => 2222. Now on port 2200.
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==> default: Forwarding ports...
default: 22 => 2200 (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2200
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
default: /vagrant => C:/cygwin64/home/kusagaya-naoki/VirtualBoxMachines/jenkins-laravel-2
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: to force provisioning. Provisioners marked to run always will still run.
$ vagrant suspend
==> default: Saving VM state and suspending execution...
$ vagrant suspend
==> default: Saving VM state and suspending execution...
$ vagrant resume
==> default: Resuming suspended VM...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection refused. Retrying...
==> default: Machine booted and ready!
$ vagrant resume
==> default: Resuming suspended VM...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2200
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection refused. Retrying...
==> default: Machine booted and ready!
#!/bin/sh
# chkconfig: 2345 70 30
# description: jenkins
# processname: jenkins
java -jar /usr/lib/jenkins/jenkins.war &
---
- hosts: "target_host"
sudo: yes
remote_user: vagrant
tasks:
- name: JavaのOpenJDKをインストール
yum: name=java-1.8.0-openjdk state=latest
- name: JavaのOpenJDK develをインストール
yum: name=java-1.8.0-openjdk-devel state=latest
- name: Jenkinsのwarファイルの設置用ディレクトリを作成
file: dest=/usr/lib/jenkins state=directory
- name: jenkins.warファイルをサイトからダウンロード
get_url: url=http://mirrors.jenkins-ci.org/war/latest/jenkins.war
dest=/usr/lib/jenkins
- name: ホストPCに置いておいたjenkins.shをリモートPCへコピー
template: src=files/jenkins.sh
dest=/etc/init.d/jenkins
mode=0777
- name: chkconfigにjenkinsを登録
action: command chkconfig --add jenkins
- name: jenkinsの起動レベルを変更
action: command chkconfig --level 2345 jenkins on
- name: jenkinsを起動
service: name=jenkins state=started enabled=yes
sudo: no
- name: jenkinsのcliツールをダウンロード
get_url: url=http://localhost:8080/jnlpJars/jenkins-cli.jar
dest=/tmp
- name: プラグインをインストール [build-pipeline-plugin]
action: command java -jar /tmp/jenkins-cli.jar -s http://localhost:8080 install-plugin build-pipeline-plugin
- name: プラグインをインストール [timestamper]
action: command java -jar /tmp/jenkins-cli.jar -s http://localhost:8080 install-plugin timestamper
- name: プラグインをインストール [git]
action: command java -jar /tmp/jenkins-cli.jar -s http://localhost:8080 install-plugin git
- name: プラグインをインストール [jobConfigHistory]
action: command java -jar /tmp/jenkins-cli.jar -s http://localhost:8080 install-plugin jobConfigHistory
- name: プラグインをインストール [cron_column]
action: command java -jar /tmp/jenkins-cli.jar -s http://localhost:8080 install-plugin cron_column
- name: プラグインをインストール [next-executions]
action: command java -jar /tmp/jenkins-cli.jar -s http://localhost:8080 install-plugin next-executions
- name: プラグインをインストール [ssh]
action: command java -jar /tmp/jenkins-cli.jar -s http://localhost:8080 install-plugin ssh
- name: jenkins restart
action: command java -jar /tmp/jenkins-cli.jar -s http://localhost:8080 safe-restart
java -jar /tmp/jenkins-cli.jar -s http://localhost:8080 install-plugin XXXXXX
と記載する必要があるのですが、このXXXXXの部分はPluginIDを入れる必要がある。$ vagrant init box-name
$ vi Vagrantfile
$ vagrant up
$ vagrant destroy
$ vim Vagrantfile
Vagrantfileの中身を修正(但しvb.nameは同じ)
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'centos6.4-30gb'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: jenkins-laravel
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.
Command: ["modifyvm", "a36f7bef-e56e-4686-91a4-a649a92f3a17", "--name", "jenkins-laravel"]
Stderr: VBoxManage.exe: error: Could not rename the directory 'C:\Users\username\VirtualBox VMs\vagrant-centos64_1_1427941735336_99768' to 'C:\Users\username\VirtualBox VMs\jenkins-laravel' to save the settings file (VERR_ALREADY_EXISTS)
VBoxManage.exe: error: Details: code E_FAIL (0x80004005), component SessionMachine, interface IMachine, callee IUnknown
VBoxManage.exe: error: Context: "SaveSettings()" at line 2716 of file VBoxManageModifyVM.cpp
C:\Users\username\VirtualBox VMs\jenkins-laravel
のフォルダが消えていなかったため、重複していてリネームできなかった事が原因だった。
user_name@computer_name ~
$ gem install serverspec
DL is deprecated, please use Fiddle
Fetching: rspec-support-3.2.1.gem (100%)
Successfully installed rspec-support-3.2.1
Fetching: rspec-mocks-3.2.0.gem (100%)
Successfully installed rspec-mocks-3.2.0
Fetching: rspec-expectations-3.2.0.gem (100%)
Successfully installed rspec-expectations-3.2.0
Fetching: rspec-core-3.2.0.gem (100%)
Successfully installed rspec-core-3.2.0
Fetching: rspec-3.2.0.gem (100%)
Successfully installed rspec-3.2.0
Fetching: rspec-its-1.1.0.gem (100%)
Successfully installed rspec-its-1.1.0
Fetching: multi_json-1.10.1.gem (100%)
Successfully installed multi_json-1.10.1
Fetching: net-scp-1.2.1.gem (100%)
Successfully installed net-scp-1.2.1
Fetching: specinfra-2.12.7.gem (100%)
Successfully installed specinfra-2.12.7
Fetching: serverspec-2.8.2.gem (100%)
Successfully installed serverspec-2.8.2
Parsing documentation for multi_json-1.10.1
Installing ri documentation for multi_json-1.10.1
Parsing documentation for net-scp-1.2.1
Installing ri documentation for net-scp-1.2.1
Parsing documentation for rspec-3.2.0
Installing ri documentation for rspec-3.2.0
Parsing documentation for rspec-core-3.2.0
Installing ri documentation for rspec-core-3.2.0
Parsing documentation for rspec-expectations-3.2.0
Installing ri documentation for rspec-expectations-3.2.0
Parsing documentation for rspec-its-1.1.0
Installing ri documentation for rspec-its-1.1.0
Parsing documentation for rspec-mocks-3.2.0
Installing ri documentation for rspec-mocks-3.2.0
Parsing documentation for rspec-support-3.2.1
Installing ri documentation for rspec-support-3.2.1
Parsing documentation for serverspec-2.8.2
Installing ri documentation for serverspec-2.8.2
Parsing documentation for specinfra-2.12.7
Installing ri documentation for specinfra-2.12.7
Done installing documentation for multi_json, net-scp, rspec, rspec-core, rspec-expectations, rspec-its, rspec-mocks, rspec-support, serverspec, specinfra after 40 seconds
10 gems installed
user_name@computer_name ~
$ cd VirtualBoxMachines/test
user_name@computer_name ~/VirtualBoxMachines/test
$ serverspec-init
DL is deprecated, please use Fiddle
Select OS type:
1) UN*X
2) Windows
Select number: 1 ← serverspecでチェックするマシンがUnix系なのかWindows系なのかを選択
Select a backend type:
1) SSH
2) Exec (local)
Select number: 1 ← SSHで接続するリモートサーバなのか、ローカルサーバなのか。
Vagrant instance y/n: y ← Vagrantで作成したマシンなのか
Auto-configure Vagrant from Vagrantfile? y/n: y ← Vagrantfileを元にしてserverspecの設定ファイルを勝手に作ってくれる
+ spec/
+ spec/default/
+ spec/default/sample_spec.rb
+ spec/spec_helper.rb
+ Rakefile
+ .rspec
user_name@computer_name ~/VirtualBoxMachines/test
$ rake spec
rake aborted!
Circular dependency detected: TOP => spec => spec:all => spec:default => spec:all
Tasks: TOP => spec => spec:all => spec:default
(See full trace by running task with --trace)
user_name@computer_name ~/VirtualBoxMachines/test
$ vim Rakefile
require 'rake'
require 'rspec/core/rake_task'
task :spec => 'spec:all'
task :default => :spec
namespace :spec do
targets = []
Dir.glob('./spec/*').each do |dir|
next unless File.directory?(dir)
targets << File.basename(dir)
end
task :all => targets
# task :default => :all ← ここをコメントアウトする
targets.each do |target|
desc "Run serverspec tests to #{target}"
RSpec::Core::RakeTask.new(target.to_sym) do |t|
ENV['TARGET_HOST'] = target
t.pattern = "spec/#{target}/*_spec.rb"
end
end
end
user_name@computer_name ~/VirtualBoxMachines/test
$ rake spec
/usr/local/bin/ruby.exe -I'/usr/local/lib/ruby/gems/2.1.0/gems/rspec-support-3.2.1/lib':'/usr/local/lib/ruby/gems/2.1.0/gems/rspec-core-3.2.0/lib' '/usr/local/lib/ruby/gems/2.1.0/gems/rspec-core-3.2.0/exe/rspec' --pattern 'spec/default/*_spec.rb'
DL is deprecated, please use Fiddle
Package "httpd"
should be installed (FAILED - 1)
Service "httpd"
should be enabled (FAILED - 2)
should be running (FAILED - 3)
Port "80"
should be listening (FAILED - 4)
Failures:
1) Package "httpd" should be installed
On host `default'
Failure/Error: it { should be_installed }
expected Package "httpd" to be installed
sudo -p 'Password: ' /bin/sh -c rpm\ -q\ httpd
package httpd is not installed
# ./spec/default/sample_spec.rb:4:in `block (2 levels) in '
2) Service "httpd" should be enabled
On host `default'
Failure/Error: it { should be_enabled }
expected Service "httpd" to be enabled
sudo -p 'Password: ' /bin/sh -c chkconfig\ --list\ httpd\ \|\ grep\ 3:on
# ./spec/default/sample_spec.rb:8:in `block (2 levels) in '
3) Service "httpd" should be running
On host `default'
Failure/Error: it { should be_running }
expected Service "httpd" to be running
sudo -p 'Password: ' /bin/sh -c ps\ aux\ \|\ grep\ -w\ --\ httpd\ \|\ grep\ -qv\ grep
# ./spec/default/sample_spec.rb:9:in `block (2 levels) in '
4) Port "80" should be listening
On host `default'
Failure/Error: it { should be_listening }
expected Port "80" to be listening
sudo -p 'Password: ' /bin/sh -c netstat\ -tunl\ \|\ grep\ --\ :80\\\
# ./spec/default/sample_spec.rb:13:in `block (2 levels) in '
Finished in 0.33207 seconds (files took 19.95 seconds to load)
4 examples, 4 failures
Failed examples:
rspec ./spec/default/sample_spec.rb:4 # Package "httpd" should be installed
rspec ./spec/default/sample_spec.rb:8 # Service "httpd" should be enabled
rspec ./spec/default/sample_spec.rb:9 # Service "httpd" should be running
rspec ./spec/default/sample_spec.rb:13 # Port "80" should be listening
/usr/local/bin/ruby.exe -I'/usr/local/lib/ruby/gems/2.1.0/gems/rspec-support-3.2.1/lib':'/usr/local/lib/ruby/gems/2.1.0/gems/rspec-core-3.2.0/lib' '/usr/local/lib/ruby/gems/2.1.0/gems/rspec-core-3.2.0/exe/rspec' --pattern 'spec/default/*_spec.rb' failed
user_name@computer_name ~/VirtualBoxMachines/test
$ rake spec
/usr/local/bin/ruby.exe -I'/usr/local/lib/ruby/gems/2.1.0/gems/rspec-support-3.2.1/lib':'/usr/local/lib/ruby/gems/2.1.0/gems/rspec-core-3.2.0/lib' '/usr/local/lib/ruby/gems/2.1.0/gems/rspec-core-3.2.0/exe/rspec' --pattern 'spec/default/*_spec.rb'
DL is deprecated, please use Fiddle
Package "httpd"
should be installed
Service "httpd"
should be enabled
should be running
Port "80"
should be listening
Finished in 0.1375 seconds (files took 15.45 seconds to load)
4 examples, 0 failures
- name: SELinuxの現状のステータスを確認し、結果を保存する
shell: getenforce ← ステータス確認コマンド
register: is_selinux_off ← 結果を「is_selinux_off」に保存
- name: Install libselinux-python
yum: name=libselinux-python state=installed
when: is_selinux_off.stdout == 'Enforcing' ← SELinuxのステータスが「Enforcing」だった場合は処理する
- name: disable selinux
selinux: state=disabled
when: is_selinux_off.stdout == 'Enforcing' ← 上と同様
- include: reboot.yml
when: is_selinux_off.stdout == 'Enforcing' ← 上と同様
- name: SELinuxの現状のステータスを確認し、結果を保存する
shell: getenforce
register: is_selinux_off
- debug: var=is_selinux_off
when: is_selinux_off
TASK: [debug var=is_selinux_off] **********************************************
ok: [xwindow] => {
"is_selinux_off": {
"changed": true,
"cmd": "getenforce",
"delta": "0:00:00.003592",
"end": "2015-02-12 18:12:03.063290",
"invocation": {
"module_args": "getenforce",
"module_name": "shell"
},
"rc": 0,
"start": "2015-02-12 18:12:03.059698",
"stderr": "",
"stdout": "Enforcing",
"stdout_lines": [
"Enforcing"
],
"warnings": []
}
}