OCI ブロックボリュームをAnsibleでアタッチしてみる
前回の記事でインスタンス(WindowsServer)にブロックボリュームを追加したと思う。
今回は追加したブロックボリュームをインスタンスにアタッチしてみるが、ただアタッチしたのでは面白くない。
という事でAnsibleでアタッチしてみよう!!
アタッチコマンドの用意
下記図のとおり、OCIはコンソールからアタッチするコマンドを確認することができる。
「iSCSIコマンドおよび情報」をクリックすると窓が開くのでそこに記載されている三行ほどのコマンドをコピーしておく。
Ansibleコンフィグの用意
- hosts: windows tasks: - name: Automatic to msiscsi win_shell: Set-Service -Name msiscsi -StartupType Automatic - name: start to msiscsi win_shell: Start-Service msiscsi - name: portal to address win_shell: iscsicli.exe QAddTargetPortal x.x.x.x - name: QLoginTarget to volume disk win_shell: iscsicli.exe QLoginTarget iqn.2015-12.com.oracleiaas:7xxxxxxxxxxxxxxxxxxxxxxxxxxx - name: attached to volume win_shell: iscsicli.exe PersistentLoginTarget iqn.2015-12.com.oracleiaas:7xxxxxxxxxxxxxxxxxxxxxxxxxxx * x.x.x.x 3260 * * * * * * * * * * * * * *
実行結果
[root@ansible ansible]# ansible-playbook -i hosts win_iscsi_mount.yml PLAY [windows] ****************************************************************************************************** TASK [Gathering Facts] ********************************************************************************************** ok: [10.0.1.1] TASK [Automatic to msiscsi] ***************************************************************************************** changed: [10.0.1.1] TASK [start to msiscsi] ********************************************************************************************* changed: [10.0.1.1] TASK [portal to address] ******************************************************************************************** changed: [10.0.1.1] TASK [QLoginTarget to volume disk] ********************************************************************************** changed: [10.0.1.1] TASK [attached to volume] ******************************************************************************************* changed: [10.0.1.1] PLAY RECAP ********************************************************************************************************** 10.0.1.1 : ok=6 changed=5 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 [root@ansible ansible]#