FloeDesignTechnologies / ansible-nginx-drupal

Ansible role to configure Nginx for running Drupal using perusio's configuration
Apache License 2.0
22 stars 12 forks source link

Juju Charm using Ansible #1

Open sebas5384 opened 10 years ago

sebas5384 commented 10 years ago

Hey! congrats for the work!

I'm currently working in a Drupal Juju charm, but! and using the Perusio configs, and I already was considering a CM for doing that, currently it's all in shell scripts. https://github.com/TallerWebSolutions/devops/tree/master/charms/saucy/drupal

The thing is, that the charm can use Ansible, so, we can work together in this, what you say?

I give it a look at your code, and I'm worried about loosing the updates from the Perusio confs, but hey thats something we can see in the future.

pbuyle commented 10 years ago

I'm also worried about tracking changes to perusio's config for files overridden using parametrized templates. But perusio config can not be used out of the box in most case, it requires edition of the files that are overridden using template.

That's why I used the same files structure for the template, so one can easily identify which files in perusio's config a template override. It should then be easier to identify changes that need to be ported to the template.

Unfortunately, perusio's config has no release version which make it harder to keep track of the changes. I updated each template with the git reference used to retrieve the source file.

I don't known JuJu Charming, but if a charm can use Ansible, then I guess it would be a playbook. The charm playbook could use this role to configure Nginx. The playbook will still need to install Nginx separately. Either in a shell script, or using Ansible tasks/roles. So I guess you can develop a charm using an ansible playbook, and include the role in its git repository as a submodule.

If you have any shortcomings with the current state of the role, please fill an issue and if possible, suggest the change need to correct them, or create a pull request.

sebas5384 commented 10 years ago

Great! I'll start by forking then. Here's the repository of the Juju charm: https://github.com/sebas5384/charm-drupal

sebas5384 commented 10 years ago

@pbuyle I have some questions:

Thanks!

pbuyle commented 10 years ago

I'm running nginx 1.4.6, installed on Ubuntu precise64 using the nginx package from https://launchpad.net/~nginx/+archive/stable. I'm using php-fpm installed using https://travis-ci.org/NBZ4live/ansible-php-fpm.

Here are the relevant sections of my playbook.xml file

- hosts: all
  ...
  pre_tasks:
    ...
   - name: Install apt_repository dependencies packages
     apt: pkg={{ item }} state=present
     with_items:
      - python-pycurl
   - name: Add APT repositories
     apt_repository: repo="{{item}}" state=present update_cache=yes
     with_items:
       - ppa:ondrej/php5-oldstable
       - ppa:nginx/stable
   - name: Install nginx-drupal dependencies packages
     apt: pkg={{ item }} state=present
     with_items:
      - git
      - nginx
     notify:
  ...
  roles:
    ...
    - role: php-fpm
    ...
      fpm_pools:
        - pool:
            name: drupal
            vars:
             - user = www-data
             - group = www-data
             - listen = /var/run/php5-fpm.sock
             - pm = dynamic
             - pm.max_children = 5
             - pm.start_servers = 2
             - pm.min_spare_servers = 1
             - pm.max_spare_servers = 3
             - chdir = /
    ...
    - role: nginx-drupal
      nginx_drupal_sites:
        - file_name: default
          root: /var/www
          http:
            port: 80
          https:
            port: 443
            certificate: /etc/nginx/ssl/default.crt
            certificate_key: /etc/nginx/ssl/default.pem
          server_name: "{{domain}}"
          alternate_server_name: "{{fqdn}}"
      nginx_drupal_nginx_status_allowed_hosts: ["127.0.0.1", "10.0.3.0/24"]
      nginx_drupal_php_fpm_status_allowed_hosts: ["127.0.0.1", "10.0.3.0/24"]
      nginx_drupal_upload_progress: false
      nginx_drupal_aio: false
      nginx_drupal_flv_streaming: false
      nginx_drupal_mp4_streaming: false
      nginx_drupal_upstream_servers: ["unix:/var/run/php5-fpm.sock"]
      nginx_drupal_upstream_backup_servers: []
  ...

As you can see, I disable a couple of features because they weren't not supported by my nginx installation.

sebas5384 commented 10 years ago

Hey @pbuyle !! here's the charm working with the some ansible roles, and one of those is this one!

https://github.com/sebas5384/charm-drupal

Thanks!, and btw we are not going to stop sending pull requests.

PierrePaul commented 10 years ago

Very neat @sebas5384, I will try it next week.