Ansibleからsetup_air.shを実行してRaspberry PiとSORACOM Airを設定する

SORACOMでSIMカードとUSBドングルを購入して、さあRaspberry Piで設定となった時にドライバとかどうしようとなるのですが、SORACOMから設定スクリプトの setup_air.sh というものが提供されています。

dev.soracom.io

基本はこのスクリプトを実行すればSIMの通信が始まり、SORACOMのコンソールからSIMが通信が確認できるようになります。

スクリプトを実行するだけとは言え、大量にRaspberry Piを設定するのは辛いものがありAnsibleを使っています。

凄い簡単な処理ですが、SORACOM Air設定部分を抜き出してみたので、こちらに記載しておきます。

---
- name: Download soracom setup tool
  get_url:
    url: https://soracom-files.s3.amazonaws.com/setup_air.sh
    dest: /tmp/setup_air.sh
    force: true

- name: Setup soracom air
  become: true
  shell: >
    /bin/bash /tmp/setup_air.sh

- name: Delete /tmp/setup_air.sh
  become: true
  file:
    path: /tmp/setup_air.sh
    state: absent

###############
# ↓以下はwpa_supplicant.confを使ってSSH設定していた場合削除するため利用
#   記事本筋と関係無いですが良くありそうなので残しておきます
#
#- name: Delete /etc/wpa_supplicant/wpa_supplicant.conf
#  become: true
#  file:
#    path: /etc/wpa_supplicant/wpa_supplicant.conf
#    state: absent

#- name: reboot OS
#  become: true
#  shell: "sleep 5 & reboot"
#  async: 1
#  poll: 0