Skip to content

Instantly share code, notes, and snippets.

- name: sh run
raw : "show run"
register: show_run
- name: sh run output
local_action: shell /bin/echo "{{ item }}" >> /tmp/hoge # >> なのに注意。この前に書き出し先ファイルを消しておく必要があるかも
with_items: show_run.stdout_lines
# joinを使う方式では、空白が削られてしまった。
# - name: sh run output
# local_action: shell /bin/echo "{{ show_run.stdout_lines | join('\n')}}" > /tmp/hoge
sakura <--> 西海岸
ping (icmp)
round-trip min/avg/max/stddev = 117.985/118.451/127.126/1.422 ms
ぐらいの環境
QoS0
receiver:2014-01-31T10:26:35.783506, QoS:0, msgid:0, sender:2014-01-31T10:26:35.665650, diff:0:00:00.117856
---
- hosts: example
gather_facts: no
tasks:
- name: raw
raw: sleep 10 && ls / > /home/hoge/hogehoge
@shirou
shirou / wait.yml
Created February 26, 2014 08:49
wait until sshd is up.
- name: wait for ping
ping:
register: waiting
until: waiting|success
retries: 10
delay: 20
@shirou
shirou / rst
Created March 7, 2014 03:43
子要素にラベルを付ける
.. _ul:
- hoge
.. _ul-child:
- hige
- :ref:`箇条書き <ul>`
@shirou
shirou / lineinfile.yml
Created March 14, 2014 13:15
あるファイル内に特定の記述(複数行)が無いときには入れる、みたいなの
---
- hosts: localhost
sudo: no
gather_facts: no
tasks:
- shell: grep ham /tmp/testfile | grep spam # pipeを使うのでshellじゃないとだめ
register: grep # grep変数に入れる
ignore_errors: yes # エラーになっても無視する
failed_when: false # これを入れると赤い文字にならない
- lineinfile: dest=/tmp/testfile insertafter=EOF line='ham'
@shirou
shirou / mqtt.md
Last active August 29, 2015 13:57
mqttのmsgとclientのテーブル設計案。
  • msgid table

msgid tableはmsgidごとに実際のパケットを 以下の形式で保存する。

  #{msgid => #{packet => packet, ref_count => integer}}
@shirou
shirou / gist:9658377
Created March 20, 2014 06:30
zcat vs gzip module
import sys
import gzip
def zcat():
count = 0
for line in sys.stdin:
count += 1
print count
@shirou
shirou / conf.py
Created March 26, 2014 07:48
SphinxでlatexpdfjaでPDFを生成するときの設定。 (試行錯誤中)
latex_elements = {
'pointsize': '11pt',
'papersize': 'a4paper',
'transition': '',
'extraclassoptions': ',openany,oneside',
'babel': '\\usepackage[japanese]{babel}',
}
latex_docclass = {'manual': 'jreport'}
builder/html.pyのwrite_doc()で
self.env.toc_secnumbers.get(docname, {})
しているが、singlehtmlでは、docnameは必ずindexのため、空となる。
また、toc_secnumbersには
{
'aaa': {'': (9,), '#id2': (9, 1, 2), '#id3': (9, 2), '#hige': (9, 1), '#hoge': (9, 1, 1)},
'bbb': {'': (7,), '#id2': (7, 1), '#id3': (7, 2), '#id4': (7, 3), '#id5': (7, 4)},
}
というデータで入っているため、'#id2'が重複している。