2
0
mirror of https://github.com/frappe/bench.git synced 2024-11-14 09:14:04 +00:00

[fix] installer - ask password

This commit is contained in:
Anand Doshi 2016-06-28 15:06:12 +05:30
parent 68564849e6
commit 15492630af
4 changed files with 30 additions and 22 deletions

View File

@ -8,8 +8,7 @@ default_config = {
'update_bench_on_update': True,
'frappe_user': getpass.getuser(),
'shallow_clone': True,
'background_workers': 1,
'dns_multitenant': True
'background_workers': 1
}
def make_config(bench_path):

View File

@ -12,10 +12,15 @@
when: ansible_distribution_version | version_compare('16.04', 'ge')
- name: Add apt repository
apt_repository: repo='deb [arch=amd64,i386] http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.1/ubuntu {{ ansible_distribution_release }} main' state=present
apt_repository:
repo: 'deb [arch=amd64,i386] http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.1/ubuntu {{ ansible_distribution_release }} main'
state: present
become: yes
become_user: root
- name: Unattended package installation
shell: export DEBIAN_FRONTEND=noninteractive
- name: apt-get install
apt: pkg={{ item }} update_cache=yes state=present
with_items:

View File

@ -48,6 +48,11 @@ def install_bench(args):
'yum': 'sudo python get-pip.py',
})
if success:
run_os_command({
'pip': 'sudo pip install --upgrade pip setuptools',
})
# Restricting ansible version due to following bug in ansible 2.1
# https://github.com/ansible/ansible-modules-core/issues/3752
success = run_os_command({
@ -64,16 +69,28 @@ def install_bench(args):
if is_sudo_user() and not args.user and not args.production:
raise Exception('Please run this script as a non-root user with sudo privileges, but without using sudo or pass --user=USER')
if not args.user:
if args.production:
args.user = 'frappe'
else:
args.user = getpass.getuser()
# args is namespace, but we would like to use it as dict in calling function, so use vars()
if args.production and not args.user:
args.user = 'frappe'
if args.user == 'root':
raise Exception('--user cannot be root')
# create user if not exists
extra_vars = vars(args)
extra_vars.update(frappe_user=args.user)
run_playbook('develop/create_user.yml', extra_vars=extra_vars)
extra_vars.update(get_passwords(args.run_travis))
if args.production:
extra_vars.update(max_worker_connections=multiprocessing.cpu_count() * 1024)
branch = 'master' if args.production else 'develop'
extra_vars.update(branch=branch)
if args.develop:
run_playbook('develop/install.yml', sudo=True, extra_vars=extra_vars)
@ -173,26 +190,11 @@ def get_passwords(run_travis=False):
'admin_password': admin_password
}
def get_extra_vars_json(extra_args, run_travis=False):
def get_extra_vars_json(extra_args):
# We need to pass production as extra_vars to the playbook to execute conditionals in the
# playbook. Extra variables can passed as json or key=value pair. Here, we will use JSON.
json_path = os.path.join('/tmp', 'extra_vars.json')
extra_vars = dict(extra_args.items())
if extra_args.get('production'):
run_travis = extra_args.get('run_travis')
extra_vars.update(get_passwords(run_travis))
extra_vars.update(max_worker_connections=multiprocessing.cpu_count() * 1024)
branch = 'master' if extra_args.get('production') else 'develop'
extra_vars.update(branch=branch)
user = args.user or getpass.getuser()
if user == 'root':
raise Exception('--user cannot be root')
extra_vars['frappe_user'] = user
with open(json_path, mode='w') as j:
json.dump(extra_vars, j, indent=1, sort_keys=True)

View File

@ -33,6 +33,8 @@
chdir: '{{ bench_path }}'
- name: Change permissions for frappe home folder
become: yes
become_user: root
file:
dest: '{{ ansible_env.HOME }}'
owner: '{{ ansible_user_id }}'