writefreely/tasks/main.yaml
changeset 17 41034ea52480
parent 2 2556522a2a45
child 18 ea20908c3904
equal deleted inserted replaced
16:c2ff7e33d1e5 17:41034ea52480
     1 ---
     1 ---
     2 
     2 
     3 - name: install apt packages
     3 - name: add writefreely user
     4   apt: name="{{writefreely_apt_packages}}"
     4   become: yes
       
     5   user: name="{{writefreely_user}}"
     5 
     6 
     6 - name: download writefreely
     7 - name: unarchive writefreely
     7   archive:
     8   become: yes
     8     src: "{{writefreely_release}}"
     9   unarchive:
       
    10     remote_src: yes
       
    11     src: "{{writefreely_tar}}"
       
    12     dest: "/tmp/"
       
    13     creates: "/tmp/writefreely/"
       
    14     owner: "root"
       
    15     group: "root"
       
    16 
       
    17 - name: install writefreely binary
       
    18   become: yes
       
    19   command: "install -m 0755 -o {{writefreely_user}} -g {{writefreely_user}} -t /usr/local/bin /tmp/writefreely/writefreely"
       
    20   changed_when: false
       
    21 
       
    22 - name: create root dir
       
    23   become: yes
       
    24   file:
       
    25     path: "{{writefreely_dir}}"
       
    26     state: "directory"
       
    27     owner: "{{writefreely_user}}"
       
    28     group: "{{writefreely_user}}"
       
    29     mode: "0755"
       
    30   notify: reload service
       
    31 
       
    32 - name: create instance dir
       
    33   become: yes
       
    34   file:
       
    35     path: "{{writefreely_dir}}/{{writefreely_instance}}"
       
    36     state: "directory"
       
    37     owner: "{{writefreely_user}}"
       
    38     group: "{{writefreely_user}}"
       
    39     mode: "0755"
       
    40   notify: reload service
       
    41 
       
    42 - name: install static content
       
    43   become: yes
       
    44   copy:
       
    45     src: "/tmp/writefreely/"
       
    46     remote_src: yes
       
    47     dest: "{{writefreely_dir}}/{{writefreely_instance}}/"
       
    48     owner: "{{writefreely_user}}"
       
    49     group: "{{writefreely_user}}"
       
    50     mode: "0755"
       
    51 
       
    52 - name: configure
       
    53   become: yes
       
    54   template:
       
    55     src: "config.ini.j2"
       
    56     dest: "{{writefreely_dir}}/{{writefreely_instance}}/config.ini"
       
    57     mode: "0644"
       
    58     owner: "{{writefreely_user}}"
       
    59     group: "{{writefreely_user}}"
       
    60   notify: reload service
       
    61 
       
    62 - name: generate keys
       
    63   become: yes
       
    64   become_user: "{{writefreely_user}}"
       
    65   command: "writefreely keys gen"
       
    66   args:
       
    67     chdir: "{{writefreely_dir}}/{{writefreely_instance}}/"
       
    68 
       
    69 - name: check if db exists
       
    70   stat:
       
    71     path: "{{writefreely_dir}}/{{writefreely_instance}}/writefreely.db"
       
    72   register: db_file
       
    73 
       
    74 - name: create db
       
    75   become: yes
       
    76   become_user: "{{writefreely_user}}"
       
    77   command: "writefreely db init"
       
    78   args:
       
    79     chdir: "{{writefreely_dir}}/{{writefreely_instance}}/"
       
    80   when: not db_file.stat.exists
       
    81 
       
    82 - name: create admin
       
    83   become: yes
       
    84   become_user: "{{writefreely_user}}"
       
    85   command: "writefreely --create-admin admin:admin"
       
    86   args:
       
    87     chdir: "{{writefreely_dir}}/{{writefreely_instance}}/"
       
    88   when: not db_file.stat.exists
       
    89 
       
    90 - name: migrate db
       
    91   become: yes
       
    92   become_user: "{{writefreely_user}}"
       
    93   command: "writefreely db migrate"
       
    94   args:
       
    95     chdir: "{{writefreely_dir}}/{{writefreely_instance}}/"
       
    96   when: db_file.stat.exists
       
    97 
       
    98 - name: install systemd service
       
    99   become: yes
       
   100   template:
       
   101     src: "[email protected]"
       
   102     dest: "/lib/systemd/system/[email protected]"
       
   103 
       
   104 - name: ensure service is started
       
   105   become: yes
       
   106   systemd: name="writefreely@{{writefreely_instance}}.service" enabled="yes" state="started"