Skip to content

Commit

Permalink
feat: site-info deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
popstas committed Sep 24, 2017
1 parent 319762f commit cfff4d2
Show file tree
Hide file tree
Showing 2 changed files with 388 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@
mode: 0644
tags: [ server-scripts, install, configure ]

- name: site-info config
template:
src: site-info.yml.j2
dest: /etc/site-info.yml
owner: root
group: root
mode: 0644
tags: [ server-scripts, install, configure ]

- name: Configuring cron tasks
cron:
cron_file: "{{ item.cron_file | default(omit) }}"
Expand Down
379 changes: 379 additions & 0 deletions templates/site-info.yml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,379 @@
---
tests:
- name: root_path
comment: Путь к сайту
command: pwd
type: string

- name: server
comment: hostname сервера
command: hostname -f
type: string

- name: maintenance_mode
comment: Режим обслуживания
command: drs vget maintenance_mode
validate:
warning: '0'
engine: drupal
groups: info

- name: cron
comment: Наличие записи в системном кроне
command: echo $(( $(crontab -l -u $(get_pwd_user) | grep "drs cron-run \"\?$(pwd)"
| wc -l) + $(crontab -l -u $(get_pwd_user) | grep "drs cron-run-elysia \"\?$(pwd)"
| wc -l) ))
validate:
min: 1
warning:
max: 1
engine: drupal
groups: cron

- name: cache
comment: Кеш анонимов, должен быть включен
command: drs vget cache
validate: '1'
engine: drupal
groups: cache

- name: block_cache
comment: Кеш блоков
command: drs vget block_cache
validate: '1'
engine: drupal
groups: cache

- name: cache_lifetime
comment: Минимальное время жизни кэша
command: drs vget cache_lifetime
validate:
min: 300
warning:
min: 3600
engine: drupal
groups: cache

- name: page_cache_maximum_age
comment: Время жизни кэша страниц (который сбрасывается по Ctrl+F5)
command: drs vget page_cache_maximum_age
validate:
min: 300
warning:
min: 1800
engine: drupal
groups: cache

# - name: cached_pages
# comment: Загружено страниц из кеша
# command: drupal-cache-hit ${DOMAIN} /var/log/nginx/drupal_cache_hit.log.1 | grep
# HIT | cut -d' ' -f2
# engine: drupal
# groups: cache

# - name: total_pages
# comment: Всего загружено страниц
# command: drupal-cache-hit ${DOMAIN} /var/log/nginx/drupal_cache_hit.log.1 | grep
# total | cut -d' ' -f2
# engine: drupal
# groups: cache

- name: total_pages_load_time
comment: Потрачено секунд на загрузку всех страниц
command: grep "^${DOMAIN}" /var/log/nginx/drupal_cache_hit.log.1 | awk -F\" '{print
$7}' | grep -v '^$' | tr -d ' ' | awk '{ sum += $1 } END { print sum }' | cut
-d'.' -f1
groups: cache

# - name: cache_hit_percent
# comment: Процент страниц, отданных из кеша
# command: drupal-cache-hit ${DOMAIN} /var/log/nginx/drupal_cache_hit.log.1 | grep
# percent | cut -d' ' -f2
# validate:
# min: 0
# warning:
# min: 10
# engine: drupal
# groups: cache

- name: preprocess_css
comment: Сжатие CSS
command: drs vget preprocess_css
validate: '1'
engine: drupal
groups: cache

- name: preprocess_js
comment: Сжатие JS
command: drs vget preprocess_js
validate: '1'
engine: drupal
groups: cache

- name: drupal_version
_old_command: drush st | grep 'Drupal version' | cut -d':' -f2 | tr -d ' '
command: grep "'VERSION', '" includes/bootstrap.inc | head -n1 | grep -Po '\d\.\d+'
engine: drupal
type: string

- name: drupal_theme
command: drs vget theme_default
engine: drupal
type: string

- name: files_count
comment: Кол-во файлов сайта
command: find -type f | wc -l
disabled: true
groups: files

- name: dirs_count
comment: Кол-во папок сайта
command: find -type d | wc -l
disabled: true
groups: files

- name: styles_files
comment: Кол-во сгенерированных превьюшек картинок
command: test -d sites/default/files/styles && find sites/default/files/styles |
wc -l || echo 0
disabled: true
engine: drupal
groups: files

- name: count_modules
comment: Кол-во включенных модулей
command: drs modules-enabled | wc -l
validate:
max: 150
warning:
max: 100
engine: drupal
groups: modules

- name: undoc_modules
comment: Кол-во незадокументированных модулей
command: drs modules-undoc | wc -l
validate:
max: 50
warning:
max: 20
engine: drupal
groups: modules

- name: dblog
command: drs module-enabled dblog
validate: '0'
engine: drupal
groups: modules

- name: syslog
command: drs module-enabled syslog
validate: '0'
engine: drupal
groups: modules

- name: update
command: drs module-enabled update
validate: '0'
engine: drupal
groups: modules

- name: devel
command: drs module-enabled devel
validate:
warning: '0'
engine: drupal
groups: modules

- name: boost
command: drs module-enabled boost
validate:
warning: '1'
engine: drupal
groups:
- cache
- modules

- name: metatag
command: drs module-enabled metatag
validate:
warning: '1'
engine: drupal
groups:
- modules
- seo

- name: xmlsitemap
command: drs module-enabled xmlsitemap
validate:
warning: '1'
engine: drupal
groups:
- modules
- seo

- name: panels
command: drs module-enabled panels
validate: '1'
engine: drupal
groups: modules

- name: reuse_cached_404
command: drs module-enabled reuse_cached_404
validate: '1'
engine: drupal
groups:
- modules
- cache

- name: sitemap_count
comment: Кол-во ссылок в sitemap.xml, не умеет считать, когда в sitemap.xml лежат
другие sitemap.xml
command: "[ $(drs module-enabled xmlsitemap) = 1 ] && drs urls sitemap | wc -l ||
echo 0"
validate:
warning:
min: 10
engine: drupal
groups: seo

- name: h1_count
comment: Кол-во h1 на главной странице
command: wget -q -O- 'http://${DOMAIN}' | grep -c '<h1'
validate:
max: 1
warning:
min: 1
groups: seo
- name: robots_disallow
comment: Индексация заблокирована в robots.txt
command: grep -oEc '^Disallow:\s*?/$' robots.txt
validate:
max: 0
groups: seo
- name: viasite_link
comment: Кол-во ссылок на viasite.ru
command: wget -q -O- 'http://${DOMAIN}' | grep -c 'http://viasite.ru'
validate:
min: 1
groups: seo
- name: git
comment: Наличие git
command: test -d .git && echo 1 || echo 0
validate: '1'
groups: git
- name: git_clean
comment: Чистый git
disabled: true
command: git diff --quiet --ignore-submodules HEAD && echo 1 || echo 0
validate:
warning: '1'
groups:
- git
- files
# - name: db_size
# comment: Размер БД, в Мб
# command: db-size "$(drs database-settings database)"
# validate:
# max: 500
# warning:
# max: 200
# engine: drupal
# groups: db
- name: cache_form
comment: Кол-во записей в кеше форм
command: drs table-count cache_form
validate:
warning:
max: 1000
engine: drupal
groups:
- db
- cache
- name: cache_menu
comment: Кол-во записей в кеше меню
command: drs table-count cache_menu
engine: drupal
groups:
- db
- cache
- name: cache_menu_page
comment: В таблице cache_menu зачем-то кешируются пункты с привязкой к URL
command: drs sql "SELECT COUNT(*) FROM {cache_menu} WHERE cid LIKE '%:page:%'"
engine: drupal
groups:
- db
- cache
- name: watchdog_count
comment: Кол-во записей в журнале dblog
command: drs table-count watchdog
engine: drupal
groups: db
- name: node_count
comment: Кол-во нод
command: drs table-count node
engine: drupal
groups: db
- name: commerce_product_count
comment: Кол-во продуктов
command: drs table-count commerce_product
engine: drupal
groups: db
- name: taxonomy_vocabulary_count
comment: Кол-во словарей
command: drs table-count taxonomy_vocabulary
engine: drupal
groups: db
- name: taxonomy_term_data_count
comment: Кол-во терминов
command: drs table-count taxonomy_term_data
engine: drupal
groups: db
- name: url_alias_count
comment: Кол-во ЧПУ
command: drs table-count url_alias
engine: drupal
groups:
- db
- seo
- name: users_count
comment: Кол-во юзеров
command: drs table-count users
engine: drupal
groups:
- db
- users
- name: user_register
comment: Регистрация на сайте (0 - отключена, 1 - с одобрением админа, 2 - обычная
регистрация)
command: drs vget user_register
validate:
max: 1
warning:
max: 0
engine: drupal
groups: users
- name: drupal_bootstrap_full
comment: Время загрузки Drupal bootstrap (msec)
command: drs bootstrap-timings | grep 'DRUPAL_BOOTSTRAP_FULL' | cut -d':' -f 2 |
tr -d ' '
engine: drupal
type: time

0 comments on commit cfff4d2

Please sign in to comment.