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 Last revision Both sides next revision | ||
os:linux:user:index.html [2018/01/06 23:08] kurihara [Operation] |
os:linux:user:index.html [2018/07/11 00:41] 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 | ||
+ | | ||
+ | </ | ||
+ | ==== Example ==== | ||
+ | |||
+ | <sxh bash toolbar: | ||
$ fab -H $H auth.pro | $ fab -H $H auth.pro | ||
+ | $ echo x.x.x.x | fab auth.pro | ||
</ | </ | ||
+ | ==== Fabric one-line Task Examples==== | ||
<sxh bash toolbar: | <sxh bash toolbar: | ||
$ H=test-server-1 | $ H=test-server-1 | ||
Line 25: | Line 49: | ||
$ fab -H $H auth.pro -- grep user01 /etc/group | $ fab -H $H auth.pro -- grep user01 /etc/group | ||
- | $ fab -H $H auth.pro -- sudo gpasswd -a user1 sudo | + | $ fab -H $H auth.pro -- sudo gpasswd -a user1 sudo # add USER to GROUP |
- | $ fab -H $H auth.pro -- sudo gpasswd -r user1 sudo | + | $ fab -H $H auth.pro -- sudo gpasswd -r user1 sudo # remove USER from GROUP |
</ | </ | ||
Line 50: | 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 63: | 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 75: | 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 179: | Line 205: | ||
sudo(" | sudo(" | ||
+ | |||
+ | # user.chpasswd_devuser02_stg | ||
+ | @task | ||
+ | def chpasswd_devuser02_stg(): | ||
+ | sudo(" | ||
# | # | ||
Line 208: | Line 239: | ||
sudo(" | sudo(" | ||
return | return | ||
- | |||
- | |||
- | # | ||
- | # etc | ||
- | # | ||
My Sites
SNS
Copyright (c) 2024 FastHandle - IT Operations Examples All Rights Reserved.