forked from groupe-sii/cheat-sheets
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from groupe-sii/develop
Update repo
- Loading branch information
Showing
32 changed files
with
737 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM node:8.1.2 | ||
COPY . . | ||
RUN if [ -n "$http_proxy" ]; then npm config set proxy $http_proxy && npm config set https-proxy $https_proxy; fi | ||
RUN npm install gulp-cli -g && npm install | ||
WORKDIR /app | ||
EXPOSE 8080 | ||
CMD gulp watch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* put your all custom css rules here */ | ||
/* you must not change other scss files */ | ||
|
||
body { | ||
// available colors are: blue, green, purple, orange and grey | ||
--currentColor: var(--blue); | ||
|
||
main div { | ||
img { | ||
height: 230px; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
Ansible version: __2.3__ - Date: __June 2017__ | ||
|
||
# Getting Started | ||
**Installation** (example on RedHat environnement) : | ||
``` | ||
$ sudo yum -y install epel-release | ||
$ sudo yum -y update | ||
$ sudo yum -y install ansible | ||
``` | ||
|
||
** Doc link : http://docs.ansible.com/ansible/latest/** | ||
|
||
# Inventory files | ||
The default file is **/etc/ansible/hosts** : | ||
``` | ||
[web] | ||
web1.sii-ouest.fr ansible_ssh_host=192.168.0.101 | ||
web2.sii-ouest.fr ansible_ssh_host=192.168.0.102 | ||
[db] | ||
db1.sii-ouest.fr ansible_ssh_host=192.168.0.100 | ||
[production:children] | ||
web | ||
db | ||
``` | ||
|
||
## Hostname ranges | ||
``` | ||
www[01:50].example.com, db-[a:f].example.com | ||
``` | ||
|
||
# Variable files | ||
- **./group_vars/web** : variable definitions for all members of group 'web' | ||
- **./host_vars/web1.sii-ouest.fr** : variable definitions for 'web1.sii-ouest.fr' | ||
|
||
# Ad-Hoc commands | ||
```ansible <pattern> -m <module> -a <params>``` | ||
|
||
Execute reboot on all servers in a group (example on production, in 10 parallel forks) : | ||
``` | ||
$ ansible production -i ./hosts all -m command -a "/sbin/reboot" -f 10 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Playbooks | ||
|
||
Execute a playbook : | ||
```ansible-playbook <playbook.yml> -i ./hosts``` | ||
|
||
Test a playbook (don't make any changes on servers) : | ||
```ansible-playbook <playbook.yml> --check``` | ||
|
||
Limit a playbook on a host : | ||
```ansible-playbook <playbook.yml> --limit <host>``` | ||
|
||
**Tasks** : | ||
``` | ||
--- | ||
- hosts: web | ||
tasks: | ||
- name: Installation of Apache Package | ||
yum: | ||
name: httpd | ||
state: present | ||
update_cache: yes | ||
- name: Ensure Apache is running (and enable it at boot) | ||
service: name=httpd state=started enabled=yes | ||
``` | ||
|
||
**Roles** (use to structure a list of Tasks): | ||
- Directory structure : | ||
``` | ||
. | ||
├── ansible.cfg | ||
├── hosts | ||
└── roles | ||
└── myrole | ||
├── defaults | ||
│ └── main.yml | ||
├── files | ||
│ └── myfile | ||
├── handlers | ||
│ └── main.yml | ||
├── tasks | ||
│ └── main.yml | ||
├── templates | ||
│ └── mytemplate.j2 | ||
└── vars | ||
└── main.yml | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<html> | ||
<head> | ||
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700|Droid+Sans:700" rel="stylesheet"> | ||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> | ||
<link rel="stylesheet" href="../common.css"> | ||
<link rel="stylesheet" href="../common/lib/atom-one-light.css"> | ||
<link rel="stylesheet" href="./@@folder.css"> | ||
</head> | ||
<body> | ||
<input type="checkbox" id="showPreview"/> | ||
<div class="first-side"> | ||
@@include('../../dist/common/first-side/header.html', {"title": "ansible cheat sheet", "subtitle": "Configuration Management Tool", "imageName": "@@folder"}) | ||
|
||
<main> | ||
<div class="column1"> | ||
@@include('../../dist/@@folder/first-side/column1.html') | ||
</div> | ||
<div class="column2"> | ||
@@include('../../dist/@@folder/first-side/column2.html') | ||
</div> | ||
</main> | ||
|
||
@@include('../../dist/common/footer.html', {"class": "print-only"}) | ||
|
||
|
||
</div> | ||
|
||
<hr class="no-print"/> | ||
|
||
<div class="reverse"> | ||
@@include('../../dist/common/reverse/header.html', {"title": "ansible cheat sheet", "imageName": "@@folder"}) | ||
|
||
<main> | ||
<div class="column1"> | ||
@@include('../../dist/@@folder/reverse/column1.html') | ||
</div> | ||
<div class="column2"> | ||
@@include('../../dist/@@folder/reverse/column2.html') | ||
</div> | ||
</main> | ||
|
||
@@include('../../dist/common/footer.html') | ||
</div> | ||
|
||
<script src="../common/lib/highlight.pack.js"></script> | ||
<script src="../common/script.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
**Handlers and Notify** : | ||
``` | ||
tasks: | ||
- name: Install Apache | ||
yum: name=httpd state=present | ||
notify: Start Apache | ||
handlers: | ||
- name: Start Apache | ||
service: name=httpd state=started | ||
``` | ||
|
||
Handlers by default get executed at the end of the playbook. | ||
|
||
**Conditionnals** : | ||
``` | ||
- name: Analyse 'my_file' | ||
shell: cat "my_file" | ||
register: my_file_contents | ||
- name: Show results | ||
shell: echo "find <toto> pattern" | ||
when: my_file_contents.stdout.find('toto') != -1 | ||
``` | ||
|
||
**Template** : Jinja Templating | ||
- **{% ... %}** for control statements | ||
- **{{ ... }}** for expressions | ||
- **{# ... #}** for comments | ||
|
||
**Tags** : | ||
Limit a playbook on tags : | ||
```ansible-playbook <playbook.yml> -i ./hosts --tag <mytag> ``` | ||
|
||
**Loops over items** : | ||
``` | ||
- name: Add a list of users | ||
user: name={{ item }} state=present | ||
with_items: | ||
- testuser1 | ||
- testuser2 | ||
- testuser3 | ||
``` | ||
|
||
## Example (Installation and conf. of Apache server): | ||
|
||
./playbook-deploy-apache.yml | ||
``` | ||
--- | ||
- hosts: web | ||
roles: | ||
- { role: demo-install-apache } | ||
- { role: demo-configure-apache } | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
./roles/demo-configure-apache/vars/main.yml | ||
``` | ||
--- | ||
apache_listen_port: 8081 | ||
app_directory: /var/www/html | ||
app_user: apache | ||
app_group: apache | ||
``` | ||
|
||
./roles/demo-configure-apache/handlers/main.yml | ||
``` | ||
--- | ||
- name: Reload Apache | ||
service: | ||
name: httpd | ||
state: reloaded | ||
``` | ||
|
||
./roles/demo-install-apache/tasks/main.yml | ||
``` | ||
--- | ||
- name: Installation of Apache Package | ||
yum: | ||
name: httpd | ||
state: present | ||
update_cache: yes | ||
- name: Ensure Apache is running (and enable it at boot) | ||
service: name=httpd state=started enabled=yes | ||
``` | ||
|
||
./roles/demo-configure-apache/tasks/main.yml | ||
``` | ||
--- | ||
- name: Modify permission of directory {{ app_directory }} | ||
file: | ||
dest: '{{ app_directory }}' | ||
mode: 0755 | ||
owner: '{{ app_user }}' | ||
group: '{{ app_group }}' | ||
recurse: yes | ||
- name: Modify Apache configuration | ||
lineinfile: | ||
dest: /etc/httpd/conf/httpd.conf | ||
regexp: '^Listen ' | ||
line: 'Listen {{ apache_listen_port }}' | ||
notify: Reload Apache | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.