summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--ansible.html.markdown472
-rw-r--r--el-gr/json-gr.html.markdown60
-rw-r--r--json.html.markdown2
-rw-r--r--perl6.html.markdown2
-rw-r--r--powershell.html.markdown1
-rw-r--r--processing.html.markdown216
-rw-r--r--zh-cn/git-cn.html.markdown2
7 files changed, 477 insertions, 278 deletions
diff --git a/ansible.html.markdown b/ansible.html.markdown
index cb365e0f..2669e5fe 100644
--- a/ansible.html.markdown
+++ b/ansible.html.markdown
@@ -3,17 +3,79 @@ category: tool
tool: ansible
contributors:
- ["Jakub Muszynski" , "http://github.com/sirkubax"]
+ - ["Pat Myron" , "https://github.com/patmyron"]
+ - ["Divay Prakash", "https://github.com/divayprakash"]
filename: LearnAnsible.txt
---
+## Introduction
+
```yaml
---
"{{ Ansible }}" is an orchestration tool written in Python.
-
+...
```
+Ansible is (one of many) orchestration tools. It allows you to control your
+environment (infrastructure and code) and automate the manual tasks.
+'You can think as simple as writing in bash with python API,
+Of course the rabbit hole is way deeper.'
+
+Ansible has great integration with multiple operating systems (even Windows)
+and some hardware (switches, Firewalls, etc). It has multiple tools that
+integrate with the cloud providers. Almost every noteworthy cloud provider is
+present in the ecosystem (AWS, Azure, Google, DigitalOcean, OVH, etc...).
+
+But ansible is way more! It provides an execution plans, an API, library,
+callbacks, not forget to mention - COMMUNITY! and great support by developers!
+
+### Main pros and cons
+
+#### Pros
+
+* It is an agent-less tools In most scenarios, it use ssh as a transport layer.
+In some way you can use it as 'bash on steroids'.
+* It is very easy to start. If you are familiar with ssh concept - you already
+know Ansible (ALMOST).
+* It executes 'as is' - other tools (salt, puppet, chef - might execute in
+different scenario than you would expect)
+* Documentation is at the world-class standard!
+* The community (github, stackOverflow) would help you very fast.
+* Writing your own modules and extensions is fairly easy.
+* Ansible AWX is the open source version of Ansible Tower we have been waiting
+for, which provides an excellent UI.
+
+#### Cons
+
+* It is an agent-less tool - every agent consumes up to 16MB ram - in some
+environments, it may be noticable amount.
+* It is agent-less - you have to verify your environment consistency
+'on-demand' - there is no built-in mechanism that would warn you about some
+change automatically (this can be achieved with reasonable effort)
+* Official GUI Tool (web inferface) - Ansible Tower - is great, but it is
+expensive.
+* There is no 'small enterprice' payment plan, however Ansible AWX is the free
+open source version we were all waiting for.
+
+#### Neutral
+
+Migration - Ansible <-> Salt is fairly easy - so if you would need an
+event-driven agent environment - it would be a good choice to start quick with
+Ansible, and convert to Salt when needed.
+
+#### Some concepts
+
+Ansible uses ssh or paramiko as a transport layer. In a way you can imagine
+that you are using a ssh with API to perform your action. The simplest way is
+to execute remote command in more controlled way (still using ssh).
+On the other hand - in advanced scope - you can wrap Ansible (use python Ansible
+code as a library) with your own Python scrips! This is awesome! It would act a
+bit like Fabric then.
+
## Example
+
An example playbook to install apache and configure log level
+
```yaml
---
- hosts: apache
@@ -23,39 +85,39 @@ An example playbook to install apache and configure log level
handlers:
- name: restart apache
- service:
+ service:
name: apache2
state: restarted
enabled: True
- notify:
+ notify:
- Wait for instances to listen on port 80
become: True
- name: reload apache
- service:
+ service:
name: apache2
state: reloaded
- notify:
+ notify:
- Wait for instances to listen on port 80
become: True
- name: Wait for instances to listen on port 80
- wait_for:
- state: started
- host: localhost
- port: 80
- timeout: 15
+ wait_for:
+ state: started
+ host: localhost
+ port: 80
+ timeout: 15
delay: 5
tasks:
- - name: Update cache
- apt:
- update_cache: yes
+ - name: Update cache
+ apt:
+ update_cache: yes
cache_valid_time: 7200
become: True
- name: Install packages
- apt:
+ apt:
name={{ item }}
with_items:
- apache2
@@ -65,40 +127,43 @@ An example playbook to install apache and configure log level
become: True
- name: Configure apache2 log level
- lineinfile:
+ lineinfile:
dest: /etc/apache2/apache2.conf
line: "LogLevel {{ apache2_log_level }}"
regexp: "^LogLevel"
notify:
- reload apache
become: True
-
+...
```
## Installation
+
```bash
# Universal way
$ pip install ansible
# Debian, Ubuntu
$ apt-get install ansible
-
```
+
* [Appendix A - How do I install ansible](#infrastructure-as-a-code)
* [Additional Reading.](http://docs.ansible.com/ansible/latest/intro_installation.html)
### Your first ansible command (shell execution)
+
```bash
-# This command ping the localhost (defined in default inventory: /etc/ansible/hosts)
+# Command pings localhost (defined in default inventory: /etc/ansible/hosts)
$ ansible -m ping localhost
-# you should see this output
+# You should see this output
localhost | SUCCESS => {
- "changed": false,
+ "changed": false,
"ping": "pong"
}
-
```
+
### Shell Commands
+
There are few commands you should know about
* `ansible` (to run modules in CLI)
@@ -108,14 +173,14 @@ There are few commands you should know about
* and other!
### Module
-_program (usally python) that execute, do some work and return proper JSON output_
-This *program* perform specialized task/action (like manage instances in the cloud, execute shell command).
-
-The simplest module is called `ping` - it just returns a JSON with `pong` message.
+A program (usually python) that executes, does some work and returns proper
+JSON output. This program performs specialized task/action (like manage
+instances in the cloud, execute shell command). The simplest module is called
+`ping` - it just returns a JSON with `pong` message.
Example of modules:
-* Module: `ping` - the simplest module that is usefull to verify host connectivity
+* Module: `ping` - the simplest module that is useful to verify host connectivity
* Module: `shell` - a module that executes shell command on a specified host(s).
Example of execution - `ping`, `shell`
@@ -125,67 +190,74 @@ $ ansible -m ping all
$ ansible -m shell -a 'date; whoami' localhost #hostname_or_a_group_name
```
-* Module: `command` - executes a single command that will not be processed through the shell, so variables like $HOME or operands like `|` `;` will not work. The command module is more secure, because it will not be affected by the user’s environment. For more complex command - use shell module.
-
+* Module: `command` - executes a single command that will not be processed
+through the shell, so variables like `$HOME` or operands like ``|` `;`` will not
+work. The command module is more secure, because it will not be affected by the
+user’s environment. For more complex commands - use shell module.
```bash
$ ansible -m command -a 'date; whoami' # FAILURE
-
$ ansible -m command -a 'date' all
$ ansible -m command -a 'whoami' all
```
-* Module: `file` - performs file operations (stat, link, dir, ...)
-* Module: `raw` - executes a low-down and dirty SSH command, not going through the module subsystem (usefull to install python2.7)
+* Module: `file` - performs file operations (stat, link, dir, ...)
+* Module: `raw` - executes a low-down and dirty SSH command, not going through
+the module subsystem (useful to install python2.7)
### Task
- Execution of a single Ansible **module** is called a **task**
-
- The simplest module is called `ping` as you could see above
- Another example of the module that allow you to execute command remotly on multiple resources is called `shell`. See above how you were using them already.
+Execution of a single Ansible **module** is called a **task**. The simplest
+module is called `ping` as you could see above.
+Another example of the module that allow you to execute command remotly on
+multiple resources is called `shell`. See above how you were using them already.
### Playbook
+
**Execution plan** written in a form of script file(s) is called **playbook**.
-Playbook consist of multiple elements
+Playbook consist of multiple elements -
* a list (or group) of hosts that 'the play' is executed against
* `task(s)` or `role(s)` that are going to be executed
* multiple optional settings (like default variables, and way more)
-Playbook script language is YAML.
-
-You can think that playbook is very advanced CLI script that you are executing.
+Playbook script language is YAML. You can think that playbook is very advanced
+CLI script that you are executing.
+#### Example of the playbook
-#### Example of the playbook:
-This example-playbook would execute (on all hosts defined in the inventory) two tasks:
+This example-playbook would execute (on all hosts defined in inventory) two tasks:
* `ping` that would return message *pong*
* `shell` that execute three commands and return the output to our terminal
```yaml
- hosts: all
-
+
tasks:
- name: "ping all"
ping:
-
+
- name: "execute a shell command"
shell: "date; whoami; df -h;"
```
Run the playbook with the command:
+
```bash
$ ansible-playbook path/name_of_the_playbook.yml
```
-_Note: Example playbook is explained in the next chapter: 'Roles'
+
+Note: Example playbook is explained in the next chapter: 'Roles'
+
### More on ansible concept
### Inventory
-Inventory is a set of an objects or hosts, against which we are executing our playbooks or single tasks via shell commands
-For this few minutes, lets asume that we are using default ansible inventory (which in Debian based system is placed in /etc/ansible/hosts)
-`/etc/ansible/hosts`
+Inventory is a set of objects or hosts, against which we are executing our
+playbooks or single tasks via shell commands. For these few minutes, let's
+assume that we are using the default ansible inventory (which in Debian based
+system is placed in `/etc/ansible/hosts`).
+
```
localhost
@@ -197,18 +269,23 @@ hostB.localdomain
[a_group_of_a_groups:children]
some_group
some_other_group
-
```
+
* [Additional Reading.](http://docs.ansible.com/ansible/latest/intro_inventory.html)
+
### ansible-roles (a 'template-playbooks' with right structure)
- You already know that the tasks (modules) can be run via CLI. You also know the playbooks - the execution plans of multiple tasks (with variables and logic).
+You already know that the tasks (modules) can be run via CLI. You also know the
+playbooks - the execution plans of multiple tasks (with variables and logic).
-A concept called `role` was introduced for parts of the code (playbooks) that should be reusable.
+A concept called `role` was introduced for parts of the code (playbooks) that
+should be reusable.
-**Role** is a structured way to manage your set of tasks, variables, handlers, default settings, and way more (meta, files, templates).
-Role allows to reuse the same parts of code in multiple plybooks (you can parametrize the role 'further' during it's execution).
-It is a great way to introduce `object oriented` management for your applications.
+**Role** is a structured way to manage your set of tasks, variables, handlers,
+default settings, and way more (meta, files, templates). Roles allow reusing
+the same parts of code in multiple playbooks (you can parametrize the role
+'further' during its execution). Its a great way to introduce `object oriented`
+management for your applications.
Role can be included in your playbook (executed via your playbook).
@@ -221,40 +298,43 @@ Role can be included in your playbook (executed via your playbook).
ping:
- name: "execute a shell command"
shell: "date; whoami; df -h;"
-
- roles:
+
+ roles:
- some_role
- { role: another_role, some_variable: 'learnxiny', tags: ['my_tag'] }
-
+
pre_tasks:
- name: some pre-task
shell: echo 'this task is the last, but would be executed before roles, and before tasks'
```
#### For remaining examples we would use additional repository
-This example install ansible in `virtualenv` so it is independend from a system. You need to initialize it into your shell-context with `source environment.sh` command.
+This example install ansible in `virtualenv` so it is independend from a system.
+You need to initialize it into your shell-context with `source environment.sh`
+command.
-We are going to use repository with examples: https://github.com/sirkubax/ansible-for-learnXinYminutes
+We are going to use this repository with examples: [https://github.com/sirkubax/ansible-for-learnXinYminutes]()
```bash
-$ # The folowing example contains a shell-prompt to indicate the venv and relative path
+$ # The following example contains a shell-prompt to indicate the venv and relative path
$ git clone git@github.com:sirkubax/ansible-for-learnXinYminutes.git
user@host:~/$ cd ansible-for-learnXinYminutes
user@host:~/ansible-for-learnXinYminutes$ source environment.sh
$
$ # First lets execute the simple_playbook.yml
(venv) user@host:~/ansible-for-learnXinYminutes$ ansible-playbook playbooks/simple_playbook.yml
-
```
Run the playbook with roles example
+
```bash
$ source environment.sh
$ # Now we would run the above playbook with roles
(venv) user@host:~/ansible-for-learnXinYminutes$ ansible-playbook playbooks/simple_role.yml
```
-#### Role directory structure:
+#### Role directory structure
+
```
roles/
some_role/
@@ -268,10 +348,13 @@ roles/
```
#### Role Handlers
-Handlers are a tasks that can be triggered (notified) during execution of a playbook, but they itself execute at the very end of a playbook.
-It is a best way to restart a service, check if application port is active (successfull deployment criteria), etc.
+Handlers are tasks that can be triggered (notified) during execution of a
+playbook, but they execute at the very end of a playbook. It is the best way to
+restart a service, check if the application port is active (successful
+deployment criteria), etc.
+
+Get familiar with how you can use roles in the simple_apache_role example
-Please get familiar how you can use role in simple_apache_role example
```
playbooks/roles/simple_apache_role/
├── tasks
@@ -282,18 +365,14 @@ playbooks/roles/simple_apache_role/
### ansible - variables
-Ansible is flexible - it has 21 levels of variable precedence
-
+Ansible is flexible - it has 21 levels of variable precedence.
[read more](http://docs.ansible.com/ansible/latest/playbooks_variables.html#variable-precedence-where-should-i-put-a-variable)
-
For now you should know that CLI variables have the top priority.
-
You should also know, that a nice way to pool some data is a **lookup**
### Lookups
-Awesome tool to query data from various sources!!! Awesome!
+Awesome tool to query data from various sources!!! Awesome!
query from:
-
* pipe (load shell command output into variable!)
* file
* stream
@@ -308,6 +387,7 @@ query from:
```
You can use them in CLI too
+
```yaml
ansible -m shell -a 'echo "{{ my_variable }}"' -e 'my_variable="{{ lookup("pipe", "date") }}"' localhost
ansible -m shell -a 'echo "{{ my_variable }}"' -e 'my_variable="{{ lookup("pipe", "hostname") }}"' all
@@ -315,15 +395,16 @@ ansible -m shell -a 'echo "{{ my_variable }}"' -e 'my_variable="{{ lookup("pipe"
# Or use in playbook
(venv) user@host:~/ansible-for-learnXinYminutes$ ansible-playbook playbooks/lookup.yml
-
```
-### Register and Conditional
+### Register and Conditional
#### Register
-Another way to dynamicaly generate the variable content is a `register` command.
-`Register` is also useful to store an output of a task, and use it's value as a logic
-for execution further tasks.
+
+Another way to dynamically generate the variable content is the `register` command.
+`Register` is also useful to store an output of a task and use its value
+for executing further tasks.
+
```
(venv) user@host:~/ansible-for-learnXinYminutes$ ansible-playbook playbooks/register_and_when.yml
```
@@ -339,22 +420,25 @@ for execution further tasks.
- name: debug root_size
debug:
msg: "{{ root_size }}"
-
+
- name: debug root_size return code
debug:
msg: "{{ root_size.rc }}"
-# when: example
+# when: example
- name: Print this message when return code of 'check the system capacity' was ok
debug:
msg: "{{ root_size.rc }}"
when: root_size.rc == 0
-
+...
```
+
#### Conditionals - when:
-You can define complex logic with Ansible and Jinja functions. Most common is usage of `when:`, with some variable (often dynamicly generated in previous playbook steps with `register` or `lookup`)
+You can define complex logic with Ansible and Jinja functions. Most common is
+usage of `when:`, with some variable (often dynamically generated in previous
+playbook steps with `register` or `lookup`)
```yaml
---
@@ -365,53 +449,63 @@ You can define complex logic with Ansible and Jinja functions. Most common is us
when: some_variable in 'a string'
roles:
- { role: mid_nagios_probe, when: allow_nagios_probes }
+...
```
-
### ansible - tags, limit
You should know about a way to increase efficiency by this simple functionality
#### TAGS
-You can tag a task, role (and its tasks), include, etc, and then run only the tagged resources
- ansible-playbook playbooks/simple_playbook.yml --tags=tagA,tag_other
- ansible-playbook playbooks/simple_playbook.yml -t tagA,tag_other
+You can tag a task, role (and its tasks), include, etc, and then run only the
+tagged resources
- There are special tags:
- always
-
- --skip-tags can be used to exclude a block of code
- --list-tags to list available tags
+```
+ansible-playbook playbooks/simple_playbook.yml --tags=tagA,tag_other
+ansible-playbook playbooks/simple_playbook.yml -t tagA,tag_other
+
+There are special tags:
+ always
+
+--skip-tags can be used to exclude a block of code
+--list-tags to list available tags
+```
[Read more](http://docs.ansible.com/ansible/latest/playbooks_tags.html)
#### LIMIT
-You can limit an execution of your tasks to defined hosts
- ansible-playbook playbooks/simple_playbook.yml --limmit localhost
+You can limit an execution of your tasks to defined hosts
- --limit my_hostname
- --limit groupname
- --limit some_prefix*
- --limit hostname:group #JM
+```
+ansible-playbook playbooks/simple_playbook.yml --limit localhost
+
+--limit my_hostname
+--limit groupname
+--limit some_prefix*
+--limit hostname:group #JM
+```
### Templates
-Template is a powerfull way to deliver some (partially) dynamic content. Ansible uses **Jinja2** langueage to describe the template.
+Templates are a powerful way to deliver some (partially) dynamic content.
+Ansible uses **Jinja2** language to describe the template.
-```jinja2
+```
Some static content
{{ a_variable }}
-{% for item in loop_items %}
+{% for item in loop_items %}
this line item is {{ item }}
{% endfor %}
```
-Jinja may have some limitations, but it is a powerfull tool that you might like.
-Please examine this simple example that install apache2 and generate index.html from the template
+Jinja may have some limitations, but it is a powerful tool that you might like.
+
+Please examine this simple example that installs apache2 and generates
+index.html from the template
"playbooks/roles/simple_apache_role/templates/index.html"
```bash
@@ -420,15 +514,18 @@ $ # Now we would run the above playbook with roles
(venv) user@host:~/ansible-for-learnXinYminutes$ ansible-playbook playbooks/simple_role.yml --tags apache2
```
-
#### Jinja2 CLI
+
You can use the jinja in the CLI too
+
```bash
ansible -m shell -a 'echo {{ my_variable }}` -e 'my_variable=something, playbook_parameter=twentytwo" localhost
```
+
In fact - jinja is used to template parts of the playbooks too
+
```yaml
-#check part of this playbook: playbooks/roles/sys_debug/tasks/debug_time.yml
+# check part of this playbook: playbooks/roles/sys_debug/tasks/debug_time.yml
- local_action: shell date +'%F %T'
register: ts
become: False
@@ -438,24 +535,29 @@ In fact - jinja is used to template parts of the playbooks too
debug: msg="{{ ts.stdout }}"
when: ts is defined and ts.stdout is defined
become: False
-
```
#### Jinja2 filters
-Junja is powerfull. It has built-in many usefull functions.
-```jinja
+
+Jinja is powerful. It has many built-in useful functions.
+
+```
# get first item of the list
{{ some_list | first() }}
# if variable is undefined - use default value
{{ some_variable | default('default_value') }}
```
+
[Read More](http://docs.ansible.com/ansible/latest/playbooks_filters.html)
### ansible-vault
-To maintain **ifrastructure as a code** you need to store secrets.
- Ansible provides a way to encrypt the confidential files so you can store it in the repository, yet the files are decrypted in-fly during ansible execution.
-The best way to use the **ansible-vault** is to store the secret in some secure location, and configure ansible to use during runtime.
+To maintain **infrastructure as code** you need to store secrets. Ansible
+provides a way to encrypt confidential files so you can store them in the
+repository, yet the files are decrypted on-the-fly during ansible execution.
+
+The best way to use it is to store the secret in some secure location, and
+configure ansible to use during runtime.
```bash
# Try (this would fail)
@@ -486,36 +588,41 @@ $ ansible-vault decrypt path/somefile
```
### dynamic inventory
-You might like to know, that you can build your inventory dynamically.
-(For Ansible) inventory is just a JSON with proper structure - if you can deliver that to ansible - anything is possible.
+You might like to know, that you can build your inventory dynamically.
+(For Ansible) inventory is just JSON with proper structure - if you can
+deliver that to ansible - anything is possible.
-You do not need to invent the wheel - there are plenty ready to use inventory script for most popular Cloud provicers and a lot of in-house popular usecaseses.
+You do not need to reinvent the wheel - there are plenty of ready to use
+inventory scripts for most popular Cloud providers and a lot of in-house
+popular usecases.
[AWS example](http://docs.ansible.com/ansible/latest/intro_dynamic_inventory.html#example-aws-ec2-external-inventory-script)
```bash
-$ etc/inv/ec2.py --refresh
-
+$ etc/inv/ec2.py --refresh
$ ansible -m ping all -i etc/inv/ec2.py
```
[Read more](http://docs.ansible.com/ansible/latest/intro_dynamic_inventory.html)
### ansible profiling - callback
-Playbook execution takes some time. It is OK. First make it run, then you may like to speed things up
-Since ansible 2.x there is built-in callback for task execution profiling
+Playbook execution takes some time. It is OK. First make it run, then you may
+like to speed things up. Since ansible 2.x there is built-in callback for task
+execution profiling.
```
-vi ansible.cfg
-#set this to:
+vi ansible.cfg
+# set this to:
callback_whitelist = profile_tasks
```
### facts-cache and ansible-cmdb
-You can pool some infrmations of you environment from another hosts.
-If the informations does not change - you may consider using a facts_cache to speed things up.
+
+You can pull some information about your environment from another hosts.
+If the information does not change - you may consider using a facts_cache
+to speed things up.
```
vi ansible.cfg
@@ -531,41 +638,55 @@ fact_caching_timeout = 86400
```
I like to use `jsonfile` as my backend. It allows to use another project
-`ansible-cmdb` [(project on github)](https://github.com/fboender/ansible-cmdb) that generates a HTML page of your inventory resources. A nice 'free' addition!
+`ansible-cmdb` [(project on github)](https://github.com/fboender/ansible-cmdb) that generates a HTML page of your inventory
+resources. A nice 'free' addition!
+
+### Debugging ansible [chapter in progress]
-### debugging ansible [chapter in progres]
When your job fails - it is good to be effective with debugging.
-1. Increase verbosiy by using multiple -v **[ -vvvvv]**
-2. If variable is undefined
- - grep -R path_of_your_inventory -e missing_variable
-3. If variable (dictionary or a list) is undefined
- - grep -R path_of_your_inventory -e missing_variable
-4. Jinja template debug
+1. Increase verbosity by using multiple -v **[ -vvvvv]**
+2. If variable is undefined -
+`grep -R path_of_your_inventory -e missing_variable`
+3. If variable (dictionary or a list) is undefined -
+`grep -R path_of_your_inventory -e missing_variable`
+4. Jinja template debug
5. Strange behaviour - try to run the code 'at the destination'
-### Infrastructure as a code
-You already know, that ansible-vault allow you to store your confidential data along with your code (in repository). You can go further - and define your ansible installation and configuration as-a-code.
-See `environment.sh` to learn how to install the ansible itself inside a `virtualenv` that is not attached to your operating system (can be changed by non-privilages user), and as additional benefit - upgrading version of ansible is as easy as installing new version in new virtualenv. What is more, you can have multiple versions of Ansible present in the same time. This is very helpfull!
+### Infrastructure as code
+
+You already know, that ansible-vault allows you to store your confidential data
+along with your code (in repository). You can go further - and define your
+ansible installation and configuration as-a-code.
+See `environment.sh` to learn how to install the ansible itself inside a
+`virtualenv` that is not attached to your operating system (can be changed by
+non-privileged user), and as additional benefit - upgrading version of ansible
+is as easy as installing new version in new virtualenv. What is more, you can
+have multiple versions of Ansible present at the same time.
```bash
- # recreate ansible 2.x venv
+# recreate ansible 2.x venv
$ rm -rf venv2
$ source environment2.sh
- # execute playbook
+
+# execute playbook
(venv2)$ ansible-playbook playbooks/ansible1.9_playbook.yml # would fail - deprecated syntax
- # now lets install ansible 1.9.x next to ansible 2.x
+# now lets install ansible 1.9.x next to ansible 2.x
(venv2)$ deactivate
$ source environment.1.9.sh
- # execute playbook
+
+# execute playbook
(venv1.9)$ ansible-playbook playbooks/ansible1.9_playbook.yml # works!
- # please note that you have both venv1.9 and venv2 present - you need to (de)activate one - that is all
+# please note that you have both venv1.9 and venv2 present - you need to (de)activate one - that is all
```
#### become-user, become
-In Ansible - to become `sudo` - use the `become` parameter. Use `become_user` to specify the username.
+
+In Ansible - to become `sudo` - use the `become` parameter. Use `become_user`
+to specify the username.
+
```
- name: Ensure the httpd service is running
service:
@@ -573,97 +694,68 @@ In Ansible - to become `sudo` - use the `become` parameter. Use `become_user` to
state: started
become: true
```
-Note: You may like to execute Ansible with `--ask-sudo-pass` or add the user to sudoers file in order to allow non-supervised execution if you require 'admin' privilages.
+
+Note: You may like to execute Ansible with `--ask-sudo-pass` or add the user to
+sudoers file in order to allow non-supervised execution if you require 'admin'
+privilages.
[Read more](http://docs.ansible.com/ansible/latest/become.html)
## Tips and tricks
#### --check -C
-Always make sure that your playbook can executes in 'dry run' mode (--check), and it's execution is not declaring 'Changed' objects.
+
+Always make sure that your playbook can execute in 'dry run' mode (--check),
+and its execution is not declaring 'Changed' objects.
#### --diff -D
-Diff is usefull to see nice detail of the files changed
-It compare 'in memory' the files like `diff -BbruN fileA fileB`
+Diff is useful to see nice detail of the files changed.
+It compare 'in memory' the files like `diff -BbruN fileA fileB`.
#### Execute hosts with 'regex'
+
```bash
ansible -m ping web*
```
-####
-Host groups can be joined, negated, etc
+#### Host groups can be joined, negated, etc
```bash
ansible -m ping web*:!backend:monitoring:&allow_change
```
#### Tagging
-You should tag some (not all) objects - a task in a playbook, all tasks included form a role, etc.
-It allows you to execute the choosen parts of the playbook.
+
+You should tag some (not all) objects - a task in a playbook, all tasks
+included form a role, etc. It allows you to execute the chosen parts of the
+playbook.
#### no_logs: True
-You may see, that some roles print a lot of output in verbose mode. There is also a debug module.
-This is the place where credentials may leak. Use `no_log` to hide the output.
+
+You may see, that some roles print a lot of output in verbose mode. There is
+also a debug module. This is the place where credentials may leak. Use `no_log`
+to hide the output.
#### Debug module
+
allows to print a value to the screen - use it!
#### Register the output of a task
-You can register the output (stdout), rc (return code), stderr of a task with the `register` command.
-
-#### Conditionals: when:
-
-#### Loop: with, with_items, with_dict, with_together
-
-[Read more](http://docs.ansible.com/ansible/latest/playbooks_conditionals.html)
-
-## Introduction
-Ansible is (one of the many) orchestration tools. It allows you to controll your environment (infrastructure and a code) and automate the manual tasks.
-'You can think as simple as writing in bash with python API
-Of course the rabit hole is way deeper.'
-
-Ansible have great integration with multiple operating systems (even Windows) and some hardware (switches, Firewalls, etc). It has multiple tools that integrate with the could providers. Almost every worth-notice cloud provider is present in the ecosystem (AWS, Azure, Google, DigitalOcean, OVH, etc...)
-
-
-But ansible is way more! It provides an execution plans, an API, library, callbacks, not forget to mention - COMMUNITY! and great support by developers!
+You can register the output (stdout), rc (return code), stderr of a task with
+the `register` command.
+#### Conditionals: when:
-### Main cons and pros
+#### Loop: with, with\_items, with\_dict, with\_together
-#### Cons
-
-It is an agent-less tool - every agent consumes up to 16MB ram - in some environments, it may be noticable amount.
-It is agent-less - you have to verify your environment consistency 'on-demand' - there is no built-in mechanism that would warn you about some change automatically (this can be achieved with reasonable effort)
-Official GUI Tool (web inferface) - Ansible Tower - is great, but it is expensive. There is no 'small enterprice' payment plan, however Ansible AWX is the free open source version we were all waiting for.
-
-#### Pros
-
-It is an agent-less tools In most scenarios, it use ssh as a transport layer.
-In some way you can use it as 'bash on steroids'.
-It is very-very-very easy to start. If you are familiar with ssh concept - you already know Ansible (ALMOST). My personal record is: 'I did show "how to install and use ansible" (for simple raspberry pi cluster management) - it took me 30 seconds to deliver a complete working example !!!)'
-I do provide a training services - I'm able to teach a production-ready person - in 8 hours (1 training day)! It covers all needed to work aspects! No other tool can match this ease of use!
-It executes 'as is' - other tools (salt, puppet, chef - might execute in different scenario than you would expect)
-Documentation is at the world-class standard!
-The comunity (github, stackOverflow) would help you very fast.
-Writing own modules and extension is fairly easy.
-Ansible AWX is the open source version of Ansible Tower we have been waiting for, which provides an excellent UI.
-
-#### Neutral
-Migration Ansible<->Salt is failrly easy - so if you would need an event-driven agent environment - it would be a good choice to start quick with Ansible, and convert to salt when needed.
-
-#### Some concepts
-
-Ansible uses ssh or paramiko as a transport layer. In a way you can imagine that you are using a ssh with API to perform your action.
-The simplest way is to execute remote command in more controlled way (still using ssh).
-On the other hand - in advanced scope - you can wrap Ansible (use python Ansible code as a library) with your own Python scrips! This is awesome! It would act a bit like Fabric then.
+[Read more](http://docs.ansible.com/ansible/latest/playbooks_conditionals.html)
## Additional Resources
* [Servers For Hackers: An Ansible Tutorial](https://serversforhackers.com/c/an-ansible-tutorial)
* [A system administrator's guide to getting started with Ansible - FAST!](https://www.redhat.com/en/blog/system-administrators-guide-getting-started-ansible-fast)
* [Ansible Tower](https://www.ansible.com/products/tower) - Ansible Tower provides a web UI, dashboard and rest interface to ansible.
-* [Ansible AWX](https://github.com/ansible/awx) - The Open Sourc version of Ansible Tower. \ No newline at end of file
+* [Ansible AWX](https://github.com/ansible/awx) - The Open Source version of Ansible Tower.
diff --git a/el-gr/json-gr.html.markdown b/el-gr/json-gr.html.markdown
new file mode 100644
index 00000000..6f30d819
--- /dev/null
+++ b/el-gr/json-gr.html.markdown
@@ -0,0 +1,60 @@
+---
+language: json
+filename: json-gr.html.markdown
+contributors:
+ - ["Anna Harren", "https://github.com/iirelu"]
+ - ["Marco Scannadinari", "https://github.com/marcoms"]
+ - ["himanshu", "https://github.com/himanshu81494"]
+ - ["Michael Neth", "https://github.com/infernocloud"]
+ - ["Athanasios Emmanouilidis", "https://github.com/athanasiosem"]
+translators:
+ - ["Athanasios Emmanouilidis", "https://github.com/athanasiosem"]
+lang: el-gr
+---
+
+Το JSON (JavaScript Object Notation) είναι ένα πολύ απλό και ελαφρύ μορφότυπο ανταλλαγής δεδομένων. Όπως αναφέρεται και στην ιστοσελίδα [json.org](http://json.org), το JSON διαβάζεται και γράφεται εύκολα από τους ανθρώπους όπως επίσης αναλύεται και παράγεται εύκολα από τις μηχανές.
+
+Ένα κομμάτι JSON δηλώνει ένα από τα παρακάτω:
+
+* Μια συλλογή από ζευγάρια ονομάτων/τιμών (collection of name/value pairs) (`{ }`). Σε πολλές γλώσσες προγραμματισμού αυτό αντιστοιχεί σε ένα αντικείμενo (object), μία εγγραφή (record), μία δομή (struct), ένα λεξικό (dictionary), ένα πίνακα κατακερματισμού (hash table), μια λίστα αριθμημένη με κλειδιά (keyed list) ή έναν πίνακα συσχέτισης (associative array).
+
+* Μια ταξινομημένη λίστα τιμών (`[ ]`). Σε πολλές γλώσσες προγραμματισμού αυτό αντιστοιχεί σε ένα πίνακα (array), σε ένα διάνυσμα (vector), μία λίστα (list), ή μια ακολουθία (sequence).
+
+Αν και το JSON στην καθαρότερη του μορφή δεν έχει σχόλια (comments), οι περισσότεροι parsers θα δεχτούν σχόλια (comments) του στύλ της γλώσσας C (`//`, `/* */`). Κάποιοι parsers επίσης ανέχονται ένα εξτρά κόμμα στο τέλος (δηλαδή ένα κόμα μετά το τελευταίο στοιχείο ενός πίνακα ή μετά την τελευταία ιδιότητα ενός αντικειμένου) αλλά καλύτερα θα είναι να αποφεύγεται η χρήση του για χάρη της συμβατότητας.
+
+Υποστηριζόμενοι τύποι δεδομένων (data types):
+
+* Συμβολοσειρές (Strings): `"Γεια"`, `"\"Περικοπή.\""`, `"\u0abe"`, `"Νέα γραμμή.\n"`
+* Αριθμοί (Numbers): `23`, `0.11`, `12e10`, `3.141e-10`, `1.23e+4`
+* Αντικείμενα (Objects): `{ "κλειδί": "τιμή" }`
+* Πίνακες (Arrays): `["Τιμή1","Τιμή2","Τιμή3",]`
+* Διάφορα : `true`, `false`, `null`
+
+```json
+{
+ "κλειδί": "τιμή",
+ "κλειδιά": "πρέπει πάντα να περιβάλονται από διπλά quotes",
+ "νούμερα": 0,
+ "συμβολοσειρές": "Γεια, κόσμε. Οι χαρακτήρες unicode επιτρέπονται, καθώς και το \"escaping\".",
+ "διαδικές τιμές": true,
+ "κενό": null,
+ "μεγάλοι αριθμοί": 1.2e+100,
+ "αντικείμενα": {
+ "σχόλια": "Σήμερα έφαγα ένα μήλο.",
+ "πίνακες": [0, 1, 2, 3, "Οι πίνακες μπορούνε να περιλαμβάνουν διαφορετικούς τύπους δεδομένων", 5],
+ "αντικείμενα μέσα σε αντικείμενα": {
+ "σχόλια": "Τα αντικείμενα μπορούνε να εσωκλύουν αντικείμενα."
+ }
+ },
+
+
+ "κενό διάστημα": "Αναγνωρίζεται χωρίς πρόβλημα αλλά καλύτερα να αποφεύγεται η χρήση του.",
+ "αυτό ήταν": "Πλέον γνωρίζετε πως μπορείτε να χρησιμοποιήσετε το JSON."
+}
+```
+
+## Περαιτέρω διάβασμα
+
+* [JSON.org](http://json.org)
+
+* [JSON Tutorial](https://www.youtube.com/watch?v=wI1CWzNtE-M)
diff --git a/json.html.markdown b/json.html.markdown
index 322c7a47..3ec7a3af 100644
--- a/json.html.markdown
+++ b/json.html.markdown
@@ -6,6 +6,7 @@ contributors:
- ["Marco Scannadinari", "https://github.com/marcoms"]
- ["himanshu", "https://github.com/himanshu81494"]
- ["Michael Neth", "https://github.com/infernocloud"]
+ - ["Athanasios Emmanouilidis", "https://github.com/athanasiosem"]
---
JSON is an extremely simple data-interchange format. As [json.org](http://json.org) says, it is easy for humans to read and write and for machines to parse and generate.
@@ -14,7 +15,6 @@ A piece of JSON must represent either:
* A collection of name/value pairs (`{ }`). In various languages, this is realized as an object, record, struct, dictionary, hash table, keyed list, or associative array.
* An ordered list of values (`[ ]`). In various languages, this is realized as an array, vector, list, or sequence.
- an array/list/sequence (`[ ]`) or a dictionary/object/associated array (`{ }`).
JSON in its purest form has no actual comments, but most parsers will accept C-style (`//`, `/* */`) comments. Some parsers also tolerate a trailing comma (i.e. a comma after the last element of an array or the after the last property of an object), but they should be avoided for better compatibility.
diff --git a/perl6.html.markdown b/perl6.html.markdown
index 04f9c6e3..7c776db4 100644
--- a/perl6.html.markdown
+++ b/perl6.html.markdown
@@ -246,7 +246,7 @@ sub mutate($n is rw) {
}
my $m = 42;
-mutate $m; # $n is now 43 !
+mutate $m; # $m is now 43 !
## This works because we are passing the container $m to mutate. If we try
## to just pass a number instead of passing a variable it won't work because
diff --git a/powershell.html.markdown b/powershell.html.markdown
index 5a5050b4..f9c20607 100644
--- a/powershell.html.markdown
+++ b/powershell.html.markdown
@@ -68,6 +68,7 @@ $aString="Some string"
# Or like this:
$aNumber = 5 -as [double]
$aList = 1,2,3,4,5
+$anEmptyList = @()
$aString = $aList -join '--' # yes, -split exists also
$aHashtable = @{name1='val1'; name2='val2'}
diff --git a/processing.html.markdown b/processing.html.markdown
index fc5dc997..e437ee95 100644
--- a/processing.html.markdown
+++ b/processing.html.markdown
@@ -3,16 +3,22 @@ language: processing
filename: learnprocessing.pde
contributors:
- ["Phone Thant Ko", "http://github.com/phonethantko"]
+ - ["Divay Prakash", "https://github.com/divayprakash"]
---
+
## Introduction
-Processing is a programming language for creation of digital arts and multimedia content, allowing non-programmers to
-learn fundamentals of computer programming in a visual context.
-While the language is based on Java language,
-its syntax has been largely influenced by both Java and Javascript syntaxes. [See more here](https://processing.org/reference/)
-The language is statically typed, and also comes with its official IDE to compile and run the scripts.
+Processing is a programming language for creation of digital arts and
+multimedia content, allowing non-programmers to learn fundamentals of computer
+programming in a visual context.
+
+While the language is based on Java language, its syntax has been largely
+influenced by both Java and Javascript syntaxes. [See more here](https://processing.org/reference/)
+
+The language is statically typed, and also comes with its official IDE to
+compile and run the scripts.
-```processing
+```
/* ---------
Comments
---------
@@ -29,23 +35,28 @@ The language is statically typed, and also comes with its official IDE to compil
/* ---------------------------------------
Writing and Running Processing Programs
---------------------------------------
- */
+*/
-// In Processing, your program's entry point is a function named setup() with a void return type.
+// In Processing, the program entry point is a function named setup() with a
+// void return type.
// Note! The syntax looks strikingly similar to that of C++.
void setup() {
// This prints out the classic output "Hello World!" to the console when run.
- println("Hello World!"); // Another language with a semi-column trap, ain't it?
+ println("Hello World!"); // Another language with a semi-column trap, aint it?
}
-// Normally, we put all the static codes inside the setup() method as the name suggest since it only runs once.
+// Normally, we put all the static codes inside the setup() method as the name
+// suggest since it only runs once.
// It can range from setting the background colours, setting the canvas size.
background(color); // setting the background colour
-size(width,height,[renderer]); // setting the canvas size with optional parameter defining renderer
+size(width,height,[renderer]); // setting the canvas size with optional
+// parameter defining renderer
// You will see more of them throughout this document.
-// If you want to run the codes indefinitely, it has to be placed in draw() method.
-// draw() must exist if you want the code to run continuously and obviously, there can only be one draw() method.
+// If you want to run the codes indefinitely, it has to be placed in draw()
+// method.
+// draw() must exist if you want the code to run continuously and obviously,
+// there can only be one draw() method.
int i = 0;
void draw() {
// This block of code loops forever until stopped
@@ -54,22 +65,25 @@ void draw() {
}
// Now that we know how to write the working script and how to run it,
-// we will proceed to explore what data types and collections are supported in Processing.
+// we will proceed to explore what data types and collections are supported in
+// Processing.
/* ------------------------
Datatypes & collections
------------------------
*/
-// According to Processing References, Processing supports 8 primitive datatypes as follows.
+// According to Processing References, Processing supports 8 primitive
+// datatypes as follows.
boolean booleanValue = true; // Boolean
byte byteValueOfA = 23; // Byte
char charValueOfA = 'A'; // Char
-color colourValueOfWhiteM = color(255, 255, 255); // Colour (Specified using color() method)
+color colourValueOfWhiteM = color(255, 255, 255); // Colour (Specified using
+// color() method)
color colourValueOfWhiteH = #FFFFFF; // Colour (Specified using hash value)
int intValue = 5; // Integer (Number without decimals)
-long longValue = 2147483648L; // "L" is added to the number to mark it as a long
+long longValue = 2147483648L; // "L" is added to number to mark it as a long
float floatValue = 1.12345; // Float (32-bit floating-point numbers)
double doubleValue = 1.12345D; // Double (64-bit floating-point numbers)
@@ -79,13 +93,15 @@ double doubleValue = 1.12345D; // Double (64-bit floating-point numbers)
// they need to be converted into "int" and "float" datatypes respectively,
// using (int) and (float) syntax before passing into a function.
-// There is a whole bunch of default composite datatypes available for use in Processing.
+// There is a whole bunch of default composite datatypes available for use in
+// Processing.
// Primarily, I will brief through the most commonly used ones to save time.
// String
// While char datatype uses '', String datatype uses "" - double quotes.
String sampleString = "Hello, Processing!";
-// String can be constructed from an array of char datatypes as well. We will discuss array very soon.
+// String can be constructed from an array of char datatypes as well. We will
+// discuss array very soon.
char source = {'H', 'E', 'L', 'L', 'O'};
String stringFromSource = new String(source); // HELLO
// As in Java, strings can be concatenated using the "+" operator.
@@ -93,27 +109,29 @@ print("Hello " + "World!"); // Hello World!
// Array
// Arrays in Processing can hold any datatypes including Objects themselves.
-// Since arrays are similar to objects, they must be created with the keyword "new".
+// Since arrays are similar to objects, they must be created with the keyword
+// "new".
int[] intArray = new int[5];
int[] intArrayWithValues = {1, 2, 3}; // You can also populate with data.
// ArrayList
// Functions are similar to those of array; arraylists can hold any datatypes.
-// The only difference is arraylists resize dynamically,
-// as it is a form of resizable-array implementation of the Java "List" interface.
+// The only difference is arraylists resize dynamically, as it is a form of
+// resizable-array implementation of the Java "List" interface.
ArrayList<Integer> intArrayList = new ArrayList<Integer>();
// Object
// Since it is based on Java, Processing supports object-oriented programming.
-// That means you can basically define any datatypes of your own and manipulate them to your needs.
+// That means you can basically define any datatypes of your own and manipulate
+// them to your needs.
// Of course, a class has to be defined before for the object you want.
// Format --> ClassName InstanceName
SomeRandomClass myObject // then instantiate later
//or
SomeRandomClass myObjectInstantiated = new SomeRandomClass();
-// Processing comes up with more collections (eg. - Dictionaries and Lists) by default,
-// for the simplicity sake, I will leave them out of discussion here.
+// Processing comes up with more collections (eg. - Dictionaries and Lists) by
+// default, for the simplicity sake, I will leave them out of discussion here.
/* ------------
Maths
@@ -128,7 +146,8 @@ SomeRandomClass myObjectInstantiated = new SomeRandomClass();
3.0 / 2 // 1.5
3.0 % 2 // 1.0
-// Processing also comes with a set of functions that simplify mathematical operations.
+// Processing also comes with a set of functions that simplify mathematical
+// operations.
float f = sq(3); // f = 9.0
float p = pow(3, 3); // p = 27.0
int a = abs(-13) // a = 13
@@ -137,18 +156,21 @@ int r2 = round(3.7); // r2 = 4
float sr = sqrt(25); // sr = 5.0
// Vectors
-// Processing provides an easy way to implement vectors in its environment using PVector class.
-// It can describe a two or three dimensional vector and
+// Processing provides an easy way to implement vectors in its environment
+// using PVector class. It can describe a two or three dimensional vector and
// comes with a set of methods which are useful for matrices operations.
// You can find more information on PVector class and its functions here.
// (https://processing.org/reference/PVector.html)
// Trigonometry
-// Processing also supports trigonometric operations by supplying a set of functions.
-// sin(), cos(), tan(), asin(), acos(), atan() and also degrees() and radians() for convenient conversion.
-// However, those functions take angle in radians as the parameter so it has to be converted beforehand.
+// Processing also supports trigonometric operations by supplying a set of
+// functions. sin(), cos(), tan(), asin(), acos(), atan() and also degrees()
+// and radians() for convenient conversion.
+// However, those functions take angle in radians as the parameter so it has
+// to be converted beforehand.
float one = sin(PI/2); // one = 1.0
-// As you may have noticed, there exists a set of constants for trigonometric uses;
+// As you may have noticed, there exists a set of constants for trigonometric
+// uses;
// PI, HALF_PI, QUARTER_PI and so on...
/* -------------
@@ -168,14 +190,14 @@ if (author.getAppearance().equals("hot")) {
int i = 3;
String value = (i > 5) ? "Big" : "Small"; // "Small"
-// Switch-case structure can be used to check multiple conditions more concisely.
+// Switch-case structure can be used to check multiple conditions concisely.
int value = 2;
switch(value) {
case 0:
- print("Nought!"); // This doesn't get executed.
+ print("Nought!"); // This does not get executed.
break; // Jumps to the next statement
case 1:
- print("Getting there..."); // This again doesn't get executed.
+ print("Getting there..."); // This again does not get executed.
break;
case 2:
print("Bravo!"); // This line gets executed.
@@ -203,13 +225,16 @@ while(j > 0) {
loop(); // allows the draw() method to run forever while
noLoop(); // only allows it to run once.
redraw(); // runs the draw() method once more.
-exit(); // This stops the program. It is useful for programs with draw() running continuously.
+exit(); // This stops the program. It is useful for programs with draw()
+// running continuously.
```
+
## Drawing with Processing
-Since you will have understood the basics of the language by now, we will now look into the best part of Processing; DRAWING.
-```processing
+Since you will have understood the basics of the language by now, we will now
+look into the best part of Processing - DRAWING.
+```
/* ------
Shapes
------
@@ -233,12 +258,15 @@ triangle(x1, y1, x2, y2, x3, y3);
// Rectangle
rect(a, b, c, d, [r]); // With optional parameter defining the radius of all corners
-rect(a, b, c, d, [tl, tr, br, bl]); // With optional set of parameters defining radius of each corner
-// Draws a rectangle with {a, b} as a top left coordinate and c and d as width and height respectively.
+rect(a, b, c, d, [tl, tr, br, bl]); // With optional set of parameters defining
+// radius of each corner
+// Draws a rectangle with {a, b} as a top left coordinate and c and d as width
+// and height respectively.
// Quad
quad(x, y, x2, y2, x3, y3, x4, y4);
-// Draws a quadrilateral with parameters defining coordinates of each corner point.
+// Draws a quadrilateral with parameters defining coordinates of each corner
+// point.
// Ellipse
ellipse(x, y, width, height);
@@ -249,19 +277,23 @@ arc(x, y, width, height, start, stop, [mode]);
// While the first four parameters are self-explanatory,
// start and end defined the angles the arc starts and ends (in radians).
// Optional parameter [mode] defines the filling;
-// PIE gives pie-like outline, CHORD gives the chord-like outline and OPEN is CHORD without strokes
+// PIE gives pie-like outline, CHORD gives the chord-like outline and OPEN is
+// CHORD without strokes
// Curves
// Processing provides two implementation of curves; using curve() and bezier().
-// Since I plan to keep this simple I won't be discussing any further details.
+// Since I plan to keep this simple I wont be discussing any further details.
// However, if you want to implement it in your sketch, here are the references:
-// (https://processing.org/reference/curve_.html)(https://processing.org/reference/bezier_.html)
+// (https://processing.org/reference/curve_.html)
+// (https://processing.org/reference/bezier_.html)
// 3D Shapes
-// 3D space can be configured by setting "P3D" to the renderer parameter in size() method.
+// 3D space can be configured by setting "P3D" to the renderer parameter in
+// size() method.
size(width, height, P3D);
-// In 3D space, you will have to translate to the particular coordinate to render the 3D shapes.
+// In 3D space, you will have to translate to the particular coordinate to
+// render the 3D shapes.
// Box
box(size); // Cube with same length defined by size
@@ -270,27 +302,32 @@ box(w, h, d); // Box with width, height and depth separately defined
// Sphere
sphere(radius); // Its size is defined using the radius parameter
// Mechanism behind rendering spheres is implemented by tessellating triangles.
-// That said, how much detail being rendered is controlled by function sphereDetail(res)
+// That said, how much detail being rendered is controlled by function
+// sphereDetail(res)
// More information here: (https://processing.org/reference/sphereDetail_.html)
// Irregular Shapes
-// What if you wanted to draw something that's not made available by Processing's functions?
-// You can use beginShape(), endShape(), vertex(x,y) to define shapes by specifying each point.
-// More information here: (https://processing.org/reference/beginShape_.html)
-// You can also use custom made shapes using PShape class.(https://processing.org/reference/PShape.html)
+// What if you wanted to draw something thats not made available by Processing
+// functions?
+// You can use beginShape(), endShape(), vertex(x,y) to define shapes by
+// specifying each point. More information here:
+// (https://processing.org/reference/beginShape_.html)
+// You can also use custom made shapes using PShape class:
+// (https://processing.org/reference/PShape.html)
/* ---------------
Transformations
---------------
*/
-// Transformations are particularly useful to keep track of the coordinate space
-// and the vertices of the shapes you have drawn.
-// Particularly, matrix stack methods; pushMatrix(), popMatrix() and translate(x,y)
+// Transformations are particularly useful to keep track of the coordinate
+// space and the vertices of the shapes you have drawn. Particularly;
+// matrix stack methods; pushMatrix(), popMatrix() and translate(x,y)
pushMatrix(); // Saves the current coordinate system to the stack
// ... apply all the transformations here ...
popMatrix(); // Restores the saved coordinate system
-// Using them, the coordinate system can be preserved and visualized without causing any conflicts.
+// Using them, the coordinate system can be preserved and visualized without
+// causing any conflicts.
// Translate
translate(x, y); // Translates to point{x, y} i.e. - setting origin to that point
@@ -310,51 +347,63 @@ scale(s); // Scale the coordinate system by either expanding or contracting it.
*/
// Colours
-// As I have discussed earlier, the background colour can be configured using background() function.
-// You can define a color object beforehand and then pass it to the function as an argument.
+// As I have discussed earlier, the background colour can be configured using
+// background() function. You can define a color object beforehand and then
+// pass it to the function as an argument.
color c = color(255, 255, 255); // WHITE!
-// By default, Processing uses RGB colour scheme but it can be configured to HSB using colorMode().
-// Read here: (https://processing.org/reference/colorMode_.html)
+// By default, Processing uses RGB colour scheme but it can be configured to
+// HSB using colorMode(). Read more here:
+// (https://processing.org/reference/colorMode_.html)
background(color); // By now, the background colour should be white.
// You can use fill() function to select the colour for filling the shapes.
-// It has to be configured before you start drawing shapes so the colours gets applied.
+// It has to be configured before you start drawing shapes so the colours gets
+// applied.
fill(color(0, 0, 0));
-// If you just want to colour the outlines of the shapes then you can use stroke() function.
-stroke(255, 255, 255, 200); // stroke colour set to yellow with transparency set to a lower value.
+// If you just want to colour the outlines of the shapes then you can use
+// stroke() function.
+stroke(255, 255, 255, 200); // stroke colour set to yellow with transparency
+// set to a lower value.
// Images
-// Processing can render images and use them in several ways. Mostly stored as PImage datatype.
+// Processing can render images and use them in several ways. Mostly stored as
+// PImage datatype.
filter(shader); // Processing supports several filter functions for image manipulation.
texture(image); // PImage can be passed into arguments for texture-mapping the shapes.
+```
+
+If you want to take things further, there are more things Processing is powered
+for. Rendering models, shaders and whatnot. There's too much to cover in a
+short documentation, so I will leave them out here. Shoud you be interested,
+please check out the references.
```
-If you want to take things further, there are more things Processing is powered for. Rendering models, shaders and whatnot.
-There's too much to cover in a short documentation, so I will leave them out here. Shoud you be interested, please check out the references.
-```processing
// Before we move on, I will touch a little bit more on how to import libraries
-// so you can extend Processing's functionality to another horizon.
+// so you can extend Processing functionality to another horizon.
/* -------
Imports
-------
*/
-// The power of Processing can be further visualized when we import libraries and packages into our sketches.
+// The power of Processing can be further visualized when we import libraries
+// and packages into our sketches.
// Import statement can be written as below at the top of the source code.
import processing.something.*;
-
```
+
## DTC?
-Down To Code? Let's get our hands dirty!
+Down To Code? Let's get our hands dirty!
-Let us see an example from openprocessing to visualize how much Processing is capable of within few lines of code.
-Copy the code below into your Processing IDE and see the magic.
+Let us see an example from openprocessing to visualize how much Processing is
+capable of within few lines of code.
-```processing
+Copy the code below into your Processing IDE and see the magic.
-// Disclaimer: I did not write this program since I currently am occupied with internship and
-// this sketch is adapted from openprocessing since it shows something cool with simple codes.
+```
+// Disclaimer: I did not write this program since I currently am occupied with
+// internship and this sketch is adapted from openprocessing since it shows
+// something cool with simple codes.
// Retrieved from: (https://www.openprocessing.org/sketch/559769)
float theta;
@@ -380,8 +429,6 @@ void draw() {
}
-
-
void branch(float len) {
col=map(len, 0, 90, 150, 255);
fill(col, 0, 74);
@@ -390,7 +437,6 @@ void branch(float len) {
ellipse(0, -len, 3, 3);
len *= 0.7;
-
if (len>30) {
pushMatrix();
translate(0, -30);
@@ -406,16 +452,16 @@ void branch(float len) {
}
}
-
```
-Processing is easy to learn and is particularly useful to create multimedia contents (even in 3D) without
-having to type a lot of codes. It is so simple that you can read through the code and get a rough idea of
-the program flow.
-However, that does not apply when you introduce external libraries, packages and even your own classes.
-(Trust me! Processing projects can get real humongous...)
+Processing is easy to learn and is particularly useful to create multimedia
+contents (even in 3D) without having to type a lot of codes. It is so simple
+that you can read through the code and get a rough idea of the program flow.
+
+However, that does not apply when you introduce external libraries, packages
+and even your own classes. (Trust me! Processing projects can get real humongous...)
-## Some useful resources:
+## Some useful resources
- [Processing Website](http://processing.org)
- [Processing Sketches](http://openprocessing.org)
diff --git a/zh-cn/git-cn.html.markdown b/zh-cn/git-cn.html.markdown
index 4ef3ffb8..d471ab5d 100644
--- a/zh-cn/git-cn.html.markdown
+++ b/zh-cn/git-cn.html.markdown
@@ -131,7 +131,7 @@ $ git help init
```bash
-# 显示分支,为跟踪文件,更改和其他不同
+# 显示分支,未跟踪文件,更改和其他不同
$ git status
# 查看其他的git status的用法