Mudanças entre as edições de "Exemplo de playbook Ansible"
De Basef
(Criou a página com "Segue abaixo exemplo de playbook Ansible: <source lang="yaml"> --- - hosts: all vars: http_port: 80 max_clients: 200 sudo: yes tasks: - name: "(VisualEdito...") |
|||
(Uma revisão intermediária pelo mesmo usuário não estão sendo mostradas) | |||
Linha 80: | Linha 80: | ||
- name: "Write the Apache Virtual Host" | - name: "Write the Apache Virtual Host" | ||
sudo: yes | sudo: yes | ||
− | template: src=configuration/apache-virtual-host-model.conf dest=/etc/apache2/sites-available/ | + | template: src=configuration/apache-virtual-host-model.conf dest=/etc/apache2/sites-available/website.conf |
- name: "Enabling the Apache Virtual Host" | - name: "Enabling the Apache Virtual Host" | ||
sudo: yes | sudo: yes | ||
− | action: command a2ensite | + | action: command a2ensite website.conf |
- name: "Disabling default Virtual Host" | - name: "Disabling default Virtual Host" | ||
Linha 113: | Linha 113: | ||
- name: "Creating database" | - name: "Creating database" | ||
sudo: yes | sudo: yes | ||
− | shell: mysql --defaults-file=/etc/mysql/debian.cnf --execute="CREATE DATABASE | + | shell: mysql --defaults-file=/etc/mysql/debian.cnf --execute="CREATE DATABASE website" |
register: create_database_task | register: create_database_task | ||
ignore_errors: True | ignore_errors: True | ||
Linha 123: | Linha 123: | ||
- name: "Importing MySQL Database" | - name: "Importing MySQL Database" | ||
− | shell: mysql --defaults-file=/etc/mysql/debian.cnf | + | shell: mysql --defaults-file=/etc/mysql/debian.cnf website < /tmp/database_dump.sql |
when: create_database_task|success | when: create_database_task|success | ||
− | - name: "Changing database credentials to user, pass and db ' | + | - name: "Changing database credentials to user, pass and db 'website'" |
− | shell: mysql --defaults-file=/etc/mysql/debian.cnf --execute="GRANT ALL PRIVILEGES ON | + | shell: mysql --defaults-file=/etc/mysql/debian.cnf --execute="GRANT ALL PRIVILEGES ON website.* TO website@localhost IDENTIFIED BY 'website'" |
when: create_database_task|success | when: create_database_task|success | ||
</source> | </source> | ||
+ | [[Categoria:Ansible]] |
Edição atual tal como às 20h08min de 25 de abril de 2015
Segue abaixo exemplo de playbook Ansible:
--- - hosts: all vars: http_port: 80 max_clients: 200 sudo: yes tasks: - name: "(VisualEditor) Authentication for parsoid installation" sudo: yes command: "{{ item }}" with_items: - gpg --keyserver keys.gnupg.net --recv-keys 5C927F7C - gpg -a --export 5C927F7C | apt-key add - - name: "(VisualEditor) Add parsoid source url to sources.list" apt_repository: repo='deb [arch=amd64] http://parsoid.wmflabs.org:8080/deb wmf-production main' state=present - name: "apt-get update" sudo: yes apt: update_cache=yes # - name: "apt-get upgrade" # apt: upgrade=dist - name: "(VisualEditor) Ensure NodeJS is installed with the latest version" apt: name=nodejs state=latest - name: "(VisualEditor) Ensure Parsoid is installed with the latest version" apt: name=parsoid state=latest force=yes - name: "(VisualEditor) Write the Parsoid settings file" sudo: yes template: src=configuration/parsoid_settings.js dest=/etc/mediawiki/parsoid/settings.js - name: "(VisualEditor) Restarting Parsoid" sudo: yes service: name=parsoid state=restarted - name: "Ensure Apache is installed with the lastest version" apt: name=apache2 state=latest - name: "Enabling Apache Mod Rewrite" sudo: yes action: command a2enmod rewrite - name: "Ensure MySQL is installed with the latest version" apt: name=mysql-server state=latest - name: "Installing PHP and dependencies" action: apt pkg={{item}} state=installed with_items: - php5 - php5-cli - php5-common - php5-curl - php5-dev - php5-gd - php5-geoip - php5-imagick - php5-intl - php5-json - php5-mcrypt - php5-memcache - php5-memcached - php5-mysql - php5-oauth - php5-sqlite - php5-xcache - php5-xdebug - php5-xsl - php5-xmlrpc - name: "Ensure GIT is installed with the latest version" apt: name=git state=latest - name: "Write the Apache Virtual Host" sudo: yes template: src=configuration/apache-virtual-host-model.conf dest=/etc/apache2/sites-available/website.conf - name: "Enabling the Apache Virtual Host" sudo: yes action: command a2ensite website.conf - name: "Disabling default Virtual Host" sudo: yes action: command a2dissite 000-default.conf - name: "Replacing the Apache User" sudo: yes replace: dest=/etc/apache2/envvars regexp='APACHE_RUN_USER=www-data' replace='APACHE_RUN_USER=vagrant' - name: "Replacing the Apache Group" sudo: yes replace: dest=/etc/apache2/envvars regexp='APACHE_RUN_GROUP=www-data' replace='APACHE_RUN_GROUP=vagrant' - name: install required packages apt: pkg={{ item }} state=latest force=yes update_cache=yes with_items: - php5-dev - php5-mysql - gcc - libpcre3-dev - make - name: "Restarting Apache" sudo: yes service: name=apache2 state=restarted - name: "Creating database" sudo: yes shell: mysql --defaults-file=/etc/mysql/debian.cnf --execute="CREATE DATABASE website" register: create_database_task ignore_errors: True - name: "Copying database dump to inside the Virtual Machine" sudo: yes copy: src=database/database_dump.sql dest=/tmp/database_dump.sql when: create_database_task|success - name: "Importing MySQL Database" shell: mysql --defaults-file=/etc/mysql/debian.cnf website < /tmp/database_dump.sql when: create_database_task|success - name: "Changing database credentials to user, pass and db 'website'" shell: mysql --defaults-file=/etc/mysql/debian.cnf --execute="GRANT ALL PRIVILEGES ON website.* TO website@localhost IDENTIFIED BY 'website'" when: create_database_task|success