In this paper we address a discrete capacitated facility location problem in which customers have Bernoulli demands. The problem is formulated as a two-stage stochastic program. The goal is to define an a priori solution for the location of the facilities and for the allocation of customers to the operating facilities that minimize the expected value of the recourse function. A closed form is presented for the recourse function and an approximation is proposed for situations in which it can not be evaluated exactly. The stochastic assignment problem resulting from setting the operating facilities is studied and a procedure is proposed to approximate its optimal solution. We formulate the capacitated facility location problem with Bernoulli demands under perfect information and, finally, we propose a heuristic to find an a priori solution. Computational results are presented for the homogeneous case.