FastHandle is fast operation tools for infrastructure configurations and tests.
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
os:linux:user:index.html [2018/02/01 22:42] kurihara [Ref. Remote Shell Commands] |
os:linux:user:index.html [2019/02/11 00:39] (current) kurihara |
||
---|---|---|---|
Line 1: | Line 1: | ||
[[: | [[: | ||
- | ====== User Management (user.py)===== | + | ====== |
$FHHOME/ | $FHHOME/ | ||
Line 7: | Line 7: | ||
\\ | \\ | ||
- | ===== Operation ===== | + | ===== Operation |
+ | ==== print list of possible commands | ||
<sxh bash toolbar: | <sxh bash toolbar: | ||
- | $ fab -l |grep user | + | $ fab -l |grep -F user. |
+ | user.check_group | ||
+ | user.check_user | ||
+ | user.chpasswd_devuser01_pro | ||
+ | user.chpasswd_devuser01_qa | ||
+ | user.chpasswd_devuser01_stg | ||
+ | user.chpasswd_devuser02_pro | ||
+ | user.chpasswd_devuser02_stg | ||
+ | user.chpasswd_devuser03_pro | ||
+ | user.chpasswd_root_pro | ||
+ | user.chpasswd_root_qa | ||
+ | user.chpasswd_root_stg | ||
+ | user.useradd_dev_all | ||
+ | user.useradd_devuser01 | ||
+ | user.useradd_devuser02 | ||
+ | user.useradd_opeuser01 | ||
+ | user.userdel_devuser01 | ||
+ | | ||
+ | </ | ||
- | $ fab -H $H auth.pro | + | ==== Example ==== |
+ | |||
+ | <sxh bash toolbar: | ||
+ | $ fab -H $H user.check_user: | ||
+ | $ echo x.x.x.x | fab | ||
</ | </ | ||
- | ==== Ref. Remote Shell Commands | + | ==== Fabric one-line Task Examples==== |
<sxh bash toolbar: | <sxh bash toolbar: | ||
$ H=test-server-1 | $ H=test-server-1 | ||
- | $ fab -H $H auth.pro | + | $ fab -H $H -- hostname |
- | $ fab -H $H auth.pro | + | $ fab -H $H -- id user01 |
- | $ fab -H $H auth.pro | + | $ fab -H $H -- "cat /etc/passwd |grep user01" |
- | $ fab -H $H auth.pro | + | $ fab -H $H -- grep user01 /etc/group |
- | $ fab -H $H auth.pro | + | $ fab -H $H -- sudo gpasswd -a user1 sudo # add USER to GROUP |
- | $ fab -H $H auth.pro | + | $ fab -H $H -- sudo gpasswd -r user1 sudo # remove USER from GROUP |
</ | </ | ||
Line 51: | Line 74: | ||
<sxh python toolbar: | <sxh python toolbar: | ||
- | import sys | + | import sys, os |
from fabric.api import * | from fabric.api import * | ||
from fabric.contrib import files | from fabric.contrib import files | ||
from fabric.utils import abort | from fabric.utils import abort | ||
+ | |||
+ | FHHOME=os.environ[" | ||
# | # | ||
Line 64: | Line 89: | ||
@task | @task | ||
def check_user(user): | def check_user(user): | ||
- | """ | + | """ |
res = run(" | res = run(" | ||
if res.failed is True: | if res.failed is True: | ||
Line 76: | Line 101: | ||
@task | @task | ||
def check_group(group): | def check_group(group): | ||
- | """ | + | """ |
- | res = run(" | + | res = run(" |
if res.failed is True: | if res.failed is True: | ||
puts(red(" | puts(red(" | ||
Line 180: | Line 205: | ||
sudo(" | sudo(" | ||
+ | |||
+ | # user.chpasswd_devuser02_stg | ||
+ | @task | ||
+ | def chpasswd_devuser02_stg(): | ||
+ | sudo(" | ||
# | # | ||
Line 209: | Line 239: | ||
sudo(" | sudo(" | ||
return | return | ||
- | |||
- | |||
- | # | ||
- | # etc | ||
- | # | ||
My Sites
SNS
Copyright (c) 2025 FastHandle - IT Operations Examples All Rights Reserved.