Ansible Learning--a simple learning note

Source: Internet
Author: User
Tags crypt

1. Use Dm-crypt to create an encrypted file system. Writing shell scripts

2. Writing the Ansible,playbook file

3. Writing a Python script

Write the shell script first

#!/bin/shsudo apt-get Install dmsetup cryptsetupsudo modprobe dm-cryptecho "dd If=/dev/zero of=/home/prod/secret.img bs= 1M count=100 "sudo dd if=/dev/zero of=/home/prod/secret.img bs=1m Count=100echo"------------------------------------- ---------------------"echo" losetup/dev/loop0 ~/secret.img "sudo losetup/dev/loop0/home/prod/secret.imgecho"------ ----------------------------------------------------"sudo losetup/dev/loop0echo"------------------------------- ---------------------------"echo" cryptsetup-y create Myencryptedfilesystem/dev/loop0 "sudo cryptsetup-y create Myenc Ryptedfilesystem/dev/loop0echo "----------------------------------------------------------" sudo dmsetup lsecho "-- --------------------------------------------------------"echo" Mkfs.ext3/dev/mapper/myencryptedfilesystem "sudo Mkfs.ext3/dev/mapper/myencryptedfilesystemecho "----------------------------------------------------------" sudo Mkdir/mnt/myencryptedfilesystemecho "----------------------------------------------------------"echo" Mount/dev/mapper/myencryptedfilesystem/mnt/myencryptedfilesystem "sudo mount/dev/ Mapper/myencryptedfilesystem/mnt/myencryptedfilesystemecho "--------------------------------------------------- -------"sudo df-h/mnt/myencryptedfilesystem

Writing Playbook Files

----Hosts:cmdb  user:prod  sudo:true  tasks:   -name:install dm-crypt action:command     Sh/home/prod /svnrepos/uninstall.sh
Writing a Python script

Import commands (status, Output) = Commands.getstatusoutput (' Ansible-playbook playbook.yml ') print status, output
The result of executing the Python script is as follows






Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Ansible Learning--a simple learning note

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.