Skip to content

Commit

Permalink
Merge pull request #1 from groupe-sii/develop
Browse files Browse the repository at this point in the history
Update repo
  • Loading branch information
mpoullain authored Oct 12, 2017
2 parents ce074a6 + 40f12c3 commit 3a7b664
Show file tree
Hide file tree
Showing 32 changed files with 737 additions and 20 deletions.
7 changes: 7 additions & 0 deletions Dockerfile
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
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,40 @@ Build and reload server:

`gulp watch`

## Docker

To simplify the installation we also provide a Dockerfile to run the application in a container.

Build image:
`docker build -t cheatsheet .`

Build image w/ proxy:
`docker build -t cheatsheet --build-arg http_proxy=<proxy> --build-arg https_proxy=<proxy> .`

Add cheatsheet:
```
docker run \
-v $PWD:/app \
cheatsheet:latest gulp create-new-cheat-sheet --name <name> --category <tools|frameworks|languages>
```

`-v $PWD:/app` mounts the current directory as working directory inside the container.

Put your svg|png logo in assets/images folder
Put your commands or codes on:
- src/\<name\>/first-side/column1.md
- src/\<name\>/first-side/column2.md
- src/\<name\>/reverse/column1.md
- src/\<name\>/reverse/column2.md

Run the web server to display all the cheat-sheets:
```
docker run -ti \
-v $PWD:/app \
-p 8080:8080 \
cheatsheet:latest
```

## Print

- Hit `Ctrl+P` to generate the PDF version, using `Save as PDF`
Expand Down
Binary file added assets/images/ansible.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/docker-swarm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/docker.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
},
"license": "MIT",
"devDependencies": {
"del": "^2.2.2",
"eslint": "^3.14.0",
"del": "^3.0.0",
"eslint": "^4.2.0",
"express": "^4.14.0",
"gulp": "^3.9.1",
"gulp-clean": "^0.3.2",
Expand All @@ -23,12 +23,12 @@
"gulp-livereload": "^3.8.1",
"gulp-markdown": "^1.2.0",
"gulp-rename": "^1.2.2",
"gulp-replace": "^0.5.4",
"gulp-replace": "^0.6.1",
"gulp-sass": "^3.0.0",
"gulp-tap": "^0.1.3",
"gulp-tap": "^1.0.1",
"gulp-template": "^4.0.0",
"merge-stream": "^1.0.1",
"yargs": "^6.5.0"
"yargs": "^8.0.2"
},
"engines": {
"node": ">=6.9.0 ",
Expand Down
4 changes: 2 additions & 2 deletions src/angular-cli/first-side/column2.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
current version: __1.0.0-beta.32.3__ - Date: __Feb. 2017__
current version: __1.2.1__ - Date: __July 2017__
# Test

Running unit tests
Expand Down Expand Up @@ -26,4 +26,4 @@ Enum
Module
`ng g module my-new-module`
Module with module routes
`ng g module my-new-module --routing`
`ng g module my-new-module --routing`
2 changes: 1 addition & 1 deletion src/angular-cli/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<body>
<input type="checkbox" id="showPreview"/>
<div class="first-side">
@@include('../../dist/common/first-side/header.html', {"title": "Angular CLI cheat sheet", "subtitle": "Angular CLI for Angular applications", "imageName": "@@folder"})
@@include('../../dist/common/first-side/header.html', {"title": "Angular CLI cheat sheet", "subtitle": "CLI tool for Angular", "imageName": "@@folder"})

<main>
<div class="column1">
Expand Down
13 changes: 13 additions & 0 deletions src/ansible/ansible.scss
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;
}
}
}
43 changes: 43 additions & 0 deletions src/ansible/first-side/column1.md
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
```
47 changes: 47 additions & 0 deletions src/ansible/first-side/column2.md
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
```
48 changes: 48 additions & 0 deletions src/ansible/index.html
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>
56 changes: 56 additions & 0 deletions src/ansible/reverse/column1.md
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 }
```


49 changes: 49 additions & 0 deletions src/ansible/reverse/column2.md
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
```
4 changes: 2 additions & 2 deletions src/cordova/first-side/column1.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Cordova : __6.5.0__ - Date : __March 2017__
Cordova : __7.0.0__ - Date : __July 2017__

# NPM commands

Expand Down Expand Up @@ -50,4 +50,4 @@ You can run application on added platform
cordova run android
cordova run ios
cordova run browser
```
```
2 changes: 1 addition & 1 deletion src/cordova/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<body>
<input type="checkbox" id="showPreview"/>
<div class="first-side">
@@include('../../dist/common/first-side/header.html', {"title": "cordova cheat sheet", "subtitle": "sous titre, une description.", "imageName": "@@folder"})
@@include('../../dist/common/first-side/header.html', {"title": "cordova cheat sheet", "subtitle": "Mobile apps with HTML, CSS & JS", "imageName": "@@folder"})

<main>
<div class="column1">
Expand Down
Loading

0 comments on commit 3a7b664

Please sign in to comment.