Skip to content

Instantly share code, notes, and snippets.

View ssato's full-sized avatar

Satoru SATOH ssato

View GitHub Profile
@ssato
ssato / gist:e2f47c694dfa56bab82b9ce2ef61426f
Last active November 17, 2021 17:39
Assertive Programming in Ansible
@ssato
ssato / force_set_perm_of_files_in_google_drive
Created February 25, 2021 10:41
force_set_perm_of_files_in_google_drive
/*
*
* https://developers.google.com/apps-script/reference/drive/access
* https://developers.google.com/apps-script/reference/drive/permission
*/
function make_folder_readonly () {
const fid = "xxxxxxxxxxxxxx";
const folder = DriveApp.getFolderById(fid);
const files = folder.getFiles();
import re
_VERB_OPT_RE = re.compile(r"v+")
def verbose_flag(options, verb_re=_VERB_OPT_RE):
"""
Return computed verbosity flag.
@ssato
ssato / qiita_blog_20191209.1.md
Created March 25, 2020 18:15
Assertive Programming in Ansible

(この記事は https://qiita.com/advent-calendar/2019/ansible2 の 12/16 分の投稿です。)

概要

本記事では Assertive Programming (表明プログラミング) が堅牢な Ansible Playbook を実装するための一助となることを、いくつかの例もあげて簡単に説明します。

Ansible における変数の諸問題

Ansible Playbook 一般に対象や環境の差異などに柔軟に対応して共通化したり、またある程度の拡張性を持たせようとしたりしようとするとほぼ必ず 変数 (variable) を使うことになるでしょう。また一切変数を使わず Ansible Playbook を書くと、非常に硬直した、特定の対象、環境、設定などにしか対応できないものとなってしまいます。故に Ansible Playbook を書く際に変数がまったく登場しないということはごくまれでしょうし、変数の扱いは非常に重要であるといえます。

@ssato
ssato / qiita_blog_20191214.1.md
Created March 25, 2020 18:14
Ansibleの呼吸 肆ノ型 フィルター芸「0,1反転」- 別解: Jinja2 Macro 編

はじめに

この投稿は [Ansible 3 Advent Calendar 2019][1] の七日目の記事です。

ここでは [@sky_jokerxx][2] さんの五日目の記事 [Ansibleの呼吸 肆ノ型 フィルター芸「0,1反転」][3] の別解を Jinja2 の macro を使って実装してみます。(なおまた別の [@akira6592][4] さんの別解はこちらに: [[Ansible] 【別解】 Ansibleの呼吸 肆ノ型 フィルター芸「0,1反転」][5])

使用するファイル

御二方の記事とまったく同じように入力ファイルを用意します。 内容は同じなので手順は割愛します。

@ssato
ssato / anyconfig_cli_demo_parse_fortios(fortigate)_cli_show_firewall_policy_ouput
Created March 16, 2020 16:52
Demo to parse fortios 'show firewall policy' output using anyconfig_cli
ssato@x1-carbon-gen6% anyconfig_cli -L ~/repos/public/github.com/ssato/python-anyconfig-fortios-backend.git
Supported types: fortios, ini, json, pickle, properties, shellvars, toml, xml, yaml
File extensions:
ini: ini
js: std.json, simplejson
jsn: std.json, simplejson
json: std.json, simplejson
pickle: pickle
pkl: pickle
properties: properties
- name: Jinja 2 filter example
hosts: localhost
gather_facts: no
vars:
ansible_python_interpreter: /usr/bin/python3
input_dics:
- type: a
name: router1
- type: b
name: router2
@ssato
ssato / gist:41b9aa67de737c493e4eeda76c9c686c
Last active December 10, 2019 15:05
listing_txt_files_under_given_dir
ssato@x1-carbon-gen6% tree /tmp/4
/tmp/4
├── a
│   └── 0.txt
├── b
│   └── 1.txt
└── c
└── d
└── 3.txt
# .. seealso:: https://fedoramagazine.org/two-factor-authentication-ssh-fedora/
ssato@x1-carbon-gen6% sudo dnf install -y google-authenticator
[sudo] password for ssato:
...
Dependencies resolved.
...
Installed:
google-authenticator-1.04-4.fc30.x86_64
Complete!
@ssato
ssato / diff_output_python-molecule_spec_files
Last active May 13, 2019 15:28
An experimental pathc to unpin, relax version dependencies of molecule
ssato@x1-carbon-gen6% diff -u python-molecule.spec{.unpin,}
--- python-molecule.spec.unpin 2019-05-11 23:12:14.261507627 +0900
+++ python-molecule.spec 2019-05-11 23:12:37.541671159 +0900
@@ -15,6 +15,7 @@
URL: https://github.com/metacloud/molecule
Source0: https://github.com/metacloud/molecule/archive/%{version}.tar.gz
+Patch0: molecule-2.20.1_unpin.patch
BuildArch: noarch