+
$ su
# apt install git
# git --version
@@ -363,7 +363,7 @@ Note : mentionner l'existence de savelog. L'option "-d" de savelog permet d'util
+
$ cd /etc
$ su
# git init
@@ -374,7 +374,7 @@ Note : mentionner l'existence de savelog. L'option "-d" de savelog permet d'util
+
# echo "127.0.0.1 foo" >> /etc/hosts
# git status
# git diff [HEAD]
@@ -422,75 +422,156 @@ Couche application : HTTP, SMTP, DNS, etc.
Introduction à Ansible
Paquets pour de nombreuses distributions
+$ su
+# apt install ansible
+# ansible --version
+ansible 2.2.1.0
+ config file = /etc/ansible/ansible.cfg
+ configured module search path = Default w/o overrides
+
- command: "date"
-
-- shell: "cat foo.txt | grep bar"
-
-- copy
- src: "files/foo"
- dest: "/etc/bar"
- mode: "0644"
-
-- replace:
- dest: "/etc/ssh/sshd_config"
- regexp: '^(Match User ((?!{{ name }}).)*)$'
- replace: '\1,{{ name }}'
-
-- lineinfile:
- dest: "/etc/evocheck.cf"
- line: "IS_APTICRON=0"
- regexp: "^IS_APTICRON="
+
+ $ ansible localhost --module-name ping
+ $ ansible localhost --module-name ping --one-line
+ $ ansible localhost --module-name setup
+ $ ansible localhost --module-name setup --args "filter=ansible_mem*"
+ $ ansible localhost --module-name lineinfile --args \
+ "dest=/etc/hosts regexp=example.com line='192.168.0.25 example.com'"
+
- apt:
- name: '{{ item }}'
- update_cache: yes
- with_items: ["vim", "htop"]
-
-- apt_repository:
- repo: "deb http://mirror.evolix.org/jessie stable main"
-
-- mysql_user:
- name: mysqladmin
- password: my_password
- priv: "*.*:ALL,GRANT"
- config_file: /root/.my.cnf
-
-- sysctl:
- name: "vm.max_map_count"
- value: 262144
- sysctl_file: "/etc/sysctl.d/elasticsearch.conf"
+ ---
-- hosts: all
+ Modules
+
+ - couche d'abstraction du shell
+ - homogénéité
+ - idempotence
+
+
+ inventory/
+ ├── group_vars
+ │ ├── all.yml
+ │ ├── hypervisors.yml
+ │ └── proxies.yml
+ ├── hosts
+ ├── hosts-dev
+ └── host_vars
+ ├── stack01-data01.yml
+ ├── stack01-front01-web01.yml
+ └── stack01-front01.yml
+
+
+ kvm01 ansible_host=192.168.2.1
+ kvm02 ansible_host=192.168.2.2
- tasks:
- - shell: echo hello World
-
+ stack01-front01 ansible_host=192.168.2.1 ansible_port=22020
+ stack01-front01-web01 ansible_host=192.168.2.1 ansible_port=22101
+ stack01-data01 ansible_host=192.168.2.1 ansible_port=22010
+
+ [hypervisors]
+ kvm01
+ kvm02
+
+ [fronts]
+ stack01-front01
+
+ [dbs]
+ stack01-data01
+
+ [web]
+ stack01-front01-web01
+
+
+ ---
+ - hosts: localhost
+
+ tasks:
+ - name: example.com in /etc/hosts
+ lineinfile:
+ dest: /etc/hosts
+ regexp: example.com
+ line: '192.168.0.25 example.com'
+ state: present
+
+ $ ansible-playbook playbook.yml