Skip to content

Commit 3f02c55

Browse files
committed
Ansible
1 parent bc14323 commit 3f02c55

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+2766
-0
lines changed

ansible/Ansible-master/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
refer wiki pages for other docs
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
Ansible Vault example
2+
======================
3+
4+
### use ansible vault file
5+
6+
1. create a file to store vault password for encrypting variables
7+
8+
> echo "secret_password" > .vault_password
9+
10+
2. create a vault file that `group_vars/all` to save db password. vault password is saved in `.vault_password` which we created.
11+
12+
> ansible-vault --vault-password-file=.vault_password create group_vars/all
13+
14+
`all` file's original details:
15+
16+
```yml
17+
---
18+
db_password: test
19+
```
20+
21+
after encrypt:
22+
```
23+
$ANSIBLE_VAULT;1.1;AES256
24+
37633561393332353064356439373636306438663131666431636637313738323036623838633730
25+
6637653533306230363238656134336432623563623731390a346663646662386163626262386439
26+
65303862363734396633386630323338393931303339613063313631633465626239396261353432
27+
3665666635373534340a616561346438323866353536373139323136633962343733356565353136
28+
61636335623561646361346563396633636534653934316236396330343963373765
29+
```
30+
31+
3. place `db_password` in `roles/vault-role/tasks/main.yml`.
32+
33+
```yml
34+
# tasks file for vault-role
35+
- debug:
36+
msg: "{{db_password}}"
37+
```
38+
39+
4. run ansible playbook
40+
41+
```sh
42+
ansible-playbook --vault-password-file=.vault_password -i inventory playbook.yml
43+
```
44+
45+
then the ansible logs like this:
46+
```
47+
PLAY [node] ************************************************************************************************************************************************
48+
49+
TASK [Gathering Facts] *************************************************************************************************************************************
50+
ok: [192.168.12.10]
51+
52+
TASK [vault-role : debug] **********************************************************************************************************************************
53+
ok: [192.168.12.10] => {
54+
"msg": "test"
55+
}
56+
57+
PLAY RECAP *************************************************************************************************************************************************
58+
192.168.12.10 : ok=2 changed=0 unreachable=0 failed=0
59+
```
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# -*- mode: ruby -*-
2+
# vi: set ft=ruby :
3+
4+
# All Vagrant configuration is done below. The "2" in Vagrant.configure
5+
# configures the configuration version (we support older styles for
6+
# backwards compatibility). Please don't change it unless you know what
7+
# you're doing.
8+
Vagrant.configure(2) do |config|
9+
10+
# machine_box = "xenial-server-cloudimg-amd64-vagrant"
11+
# machine_box_url = "https://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-amd64-vagrant.box"
12+
13+
machine_box = "CentOS-7.1.1503-x86_64-netboot"
14+
15+
config.vm.define "node44" do |machine|
16+
machine.vm.box = machine_box
17+
machine.vm.hostname = "node44"
18+
machine.vm.network "private_network", ip: "192.168.12.10"
19+
machine.vm.provider "virtualbox" do |node|
20+
node.name = "node44"
21+
node.memory = 1024
22+
node.cpus = 1
23+
end
24+
end
25+
26+
27+
end
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
$ANSIBLE_VAULT;1.1;AES256
2+
37633561393332353064356439373636306438663131666431636637313738323036623838633730
3+
6637653533306230363238656134336432623563623731390a346663646662386163626262386439
4+
65303862363734396633386630323338393931303339613063313631633465626239396261353432
5+
3665666635373534340a616561346438323866353536373139323136633962343733356565353136
6+
61636335623561646361346563396633636534653934316236396330343963373765
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[node]
2+
192.168.12.10
3+
4+
5+
[all:vars]
6+
env="local-env"
7+
ansible_ssh_user="vagrant"
8+
ansible_ssh_pass="vagrant"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
- hosts: localhost
2+
vars:
3+
- foo: "bar"
4+
5+
- multiline: |
6+
test1
7+
test2
8+
roles:
9+
- vault-role
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
Role Name
2+
=========
3+
4+
A brief description of the role goes here.
5+
6+
Requirements
7+
------------
8+
9+
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
10+
11+
Role Variables
12+
--------------
13+
14+
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
15+
16+
Dependencies
17+
------------
18+
19+
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
20+
21+
Example Playbook
22+
----------------
23+
24+
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
25+
26+
- hosts: servers
27+
roles:
28+
- { role: username.rolename, x: 42 }
29+
30+
License
31+
-------
32+
33+
BSD
34+
35+
Author Information
36+
------------------
37+
38+
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
# defaults file for vault-role
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
# handlers file for vault-role

0 commit comments

Comments
 (0)