|
44 | 44 | notify: restart carbon-cache
|
45 | 45 |
|
46 | 46 | - name: Inspect graphite db
|
47 |
| - command: sudo -u {{ graphite_user }} python {{ graphite_install_path }}/webapp/graphite/manage.py inspectdb |
| 47 | + command: python {{ graphite_install_path }}/webapp/graphite/manage.py inspectdb |
| 48 | + sudo_user: "{{ graphite_user }}" |
48 | 49 | register: result
|
49 | 50 | changed_when: False
|
50 | 51 |
|
|
54 | 55 | changed_when: False
|
55 | 56 |
|
56 | 57 | - name: Sync/create database
|
57 |
| - command: sudo -u {{ graphite_user }} python {{ graphite_install_path }}/webapp/graphite/manage.py syncdb --noinput |
| 58 | + command: python {{ graphite_install_path }}/webapp/graphite/manage.py syncdb --noinput |
| 59 | + sudo_user: "{{ graphite_user }}" |
58 | 60 | when: result.stdout.find("AccountMygraph") == -1
|
59 | 61 |
|
60 |
| -- name: Install database (1/3) Upload import data |
61 |
| - template: src=dbdump.json.j2 dest=/tmp/graphite_dbdump.json |
62 |
| - when: result.stdout.find("AccountMygraph") == -1 |
63 |
| - notify: restart carbon-cache |
64 |
| - |
65 |
| -- name: Install database (2/3) Install data |
66 |
| - command: sudo -u {{ graphite_user }} python {{ graphite_install_path }}/webapp/graphite/manage.py loaddata /tmp/graphite_dbdump.json |
67 |
| - when: result.stdout.find("AccountMygraph") == -1 |
68 |
| - notify: restart carbon-cache |
69 |
| - |
70 |
| -- name: Install database (3/3) Remove temp file |
71 |
| - file: path=/tmp/graphite_dbdump.json state=absent |
72 |
| - when: result.stdout.find("AccountMygraph") == -1 |
73 |
| - notify: restart carbon-cache |
| 62 | +- name: Create superuser account |
| 63 | + command: python {{ graphite_install_path }}/webapp/graphite/manage.py createsuperuser --username={{ graphite_admin_username }} --email={{ graphite_admin_email }} --noinput |
| 64 | + sudo_user: "{{ graphite_user }}" |
| 65 | + register: superuser_created |
| 66 | + args: |
| 67 | + creates: "{{ graphite_install_path }}/webapp/graphite/.superuser_created" |
| 68 | + |
| 69 | +- name: Prepare to set up superuser password |
| 70 | + template: src=createsuperuser.py.j2 dest=/tmp/createsuperuser.py |
| 71 | + when: superuser_created|changed |
| 72 | + register: debug2 |
| 73 | + |
| 74 | +- name: Set superuser password |
| 75 | + shell: "python {{ graphite_install_path }}/webapp/graphite/manage.py shell < /tmp/createsuperuser.py" |
| 76 | + sudo_user: "{{ graphite_user }}" |
| 77 | + when: superuser_created|changed |
| 78 | + |
| 79 | +- name: Create lock file |
| 80 | + file: path="{{ graphite_install_path }}/webapp/graphite/.superuser_created" state=touch |
| 81 | + when: superuser_created|changed |
| 82 | + |
| 83 | +- name: Remove temp file |
| 84 | + file: path=/tmp/createsuperuser.py state=absent |
74 | 85 |
|
75 | 86 | - name: Make sure services are running
|
76 | 87 | service: name={{ item }} state=started
|
|
0 commit comments